SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
<Insert Picture Here>




Mysteries of the Binary Log
Mats Kindahl                  Charles Bell
Lead Replication Developer    Lead Backup Developer
About the Speakers
Mats Kindahl, PhD
•

     •
         Replication Expert and Lead Developer
     •
         mats.kindahl@sun.com
Chuck Bell, PhD
•

     •
         Enterprise Backup and Replication
     •
         chuck.bell@oracle.com
Lars Thalmann, PhD
•

     •
         Development Manager, Replication and Backup
     •
         lars.thalmann@sun.com
What is the binary log?

• Record of changes                      Master               Slave
• Used for
  – Replication
  – Auditing
  – Point-In-Time Recovery (PITR)
• Slave executes changes with privileges turned off
  – Security implications?
  – “If it is OK to execute on the master, it should be OK to execute
    on the slave”
  – Not always true (as you will see)
Best Practices
• Manage your log rotations
• Protect your logs
    – Store on secure location
    – Don't store on same disk as data
• Purge old logs
    – PURGE command
    – --expire-log-days
• Use log filters sparingly if point-in-time recovery a priority
• Protect the replication user account from tampering
• Avoid using sensitive data in statements (e.g. passwords)
Structure of the Binary Log

                                       Binlog files
                                       • Option log­bin
      Binary Log
                                       • Default master­bin.000001
                   master-bin.000001
                   master-bin.000002
                                       • Content of binary log
                   master-bin.000003


                                       Binlog index
                                       • Option log­bin­index
                                       • Default master­bin.index
    Binlog files   Index file          • Index over binlog files
Binlog file structure

                                       • Format Description Event
                                         – File-specific data
Groups                                   – Binlog Format Version
         Format Description
         INSERT INTO tbl VALUES ...      – Server Version
         BEGIN;
         UPDATE tbl SET passwd = ...   • Rotate
         UPDATE account SET value...
         COMMIT;
                                         – Terminate binlog file
                                         – Next file in sequence
                                       • Binlog Events
                                         – Organized in groups
                  Rotate
                                         – MySQL 5.1 have 26
                                           different event types
Binlog file structure

                                       • Binary Log Coordinate
         mysql­bin.000001
                                         – File name
Groups                                   – File position
         Format Description
         INSERT INTO tbl VALUES ...
         BEGIN;
         UPDATE tbl SET passwd = ...
         UPDATE account SET value...
         COMMIT;




                  Rotate
Investigating Binary Log

     • SHOW BINLOG EVENTS
          – IN file
          – FROM position
          – LIMIT events
     • Shows contents of first binlog file (!)
          – Not contents of last binlog file

mysql> SHOW BINLOG EVENTS;
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                             |
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql­bin.000001 |   4 | Format_desc |         1 |         106 | Server ver: 5.1.37­1ubuntu5.1­log, Binlog ver: 4 | 
| mysql­bin.000001 | 106 | Query       |         1 |         250 | use `test`; CREATE TABLE book (id INT UNSIGNE... | 
| mysql­bin.000001 | 250 | Query       |         1 |         373 | use `test`; CREATE TABLE author (name VARCHAR... | 
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
3 rows in set (0.00 sec)




                                 Size = End_log_pos - Pos
Purging Binlog Files

• PURGE BINARY LOG TO filename
   Deletes all binary log files before the named file.
• PURGE BINARY LOG BEFORE datetime
   Purge will always delete complete files. This means that if
   there is at least one event in the log file that has a time stamp
   after datetime, the file is not deleted.
• RESET MASTER
 – Deletes all binary log files listed in the index file, resets the
   index, and creates a new binlog file.
Purging Binlog Files

• Automatically purge logs
  – Server_variable: expire_logs_days
  – Removes the binlog files that are at least that old
  – The removal happens at server start or log flush
Binlog Event Structure

                    • Common header
                      • Generic data
   Common Header
                      • Fixed size
                    • Post-header
    Post-header       • Event-specific data
                      • Fixed size
                    • Variable part
                      • Event-specific data
    Variable Part     • Variable size
Binlog Event Common Header

                                       • Data common to all events
Timestamp        Type      Server ID
                                       • File Position
    4 bytes
                                          – End of event
                                       • Timestamp
                                          – Statement start time
                                       • Flags
                                          –   Binlog-in-use
                                          –   Thread-specific
                       File Position
                                          –   Suppress “use”
              Length
                                          –   Artificial
 Flags
              19 Bytes                    –   Relay-log event
Format Description Event
           Common Header                Binlog Format
                                           Version    •       Describes file information
             Server Version                         – Different files can have
               (50 bytes)                             different information
                                   Common Header
                                      Length        – Design for extensibility
                                        Post-header    • Common header length
                                          Lengths      • Post-header lengths
          Creation
           Time                                            • Fixed size!

mysql> SHOW BINLOG EVENTS;
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                             |
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql­bin.000001 |   4 | Format_desc |         1 |         106 | Server ver: 5.1.37­1ubuntu5.1­log, Binlog ver: 4 | 
| mysql­bin.000001 | 106 | Query       |         1 |         250 | use `test`; CREATE TABLE book (id INT UNSIGNE... | 
| mysql­bin.000001 | 250 | Query       |         1 |         373 | use `test`; CREATE TABLE author (name VARCHAR... | 
+­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
3 rows in set (0.00 sec)
Query Event

Thread ID          Execution Time     • Most common event
                                      • Used for statements
       Common Header          Status
                              Variable Statement logged literally
                                      •
                                Code     – … in almost all cases

              Query


                        Status Variable Value
  Db Length
              Error Code
              Status Variables Length
Handling Statement Context

• SQL_MODE
• Time functions
  – NOW(), CURDATE(), CURTIME(), UNIX_TIMESTAMP()
  – SYSDATE()
• Auto-increment handling
  –   Insert into AUTO_INCREMENT column
  –   Using LAST_INSERT_ID()
  –   @@auto_increment_increment
  –   @@auto_increment_offset
• User-defined variables
• Seed for RAND()
• Character set
Status Variables

• Added in query event   •   SQL_MODE
  – Only when needed     •   Catalog
                         •   auto_increment_increment
                         •   auto_increment_offset
                         •   Character Set
                         •   Time Zone
Time Functions

• Execution start time is saved for session
  – Recorded in binlog event
• Some functions use statement start time
  – NOW(), CURTIME(), CURDATE(), UNIX_TIMESTAMP()OK
• Some functions call time(2) directly
                        g   !
                    nin
  – SYSDATE()
                  ar
              W
Context Events

• Context events are used for:
  •   User-defined variables
  •   RAND() seeds
  •   AUTO_INCREMENT
  •   LAST_INSERT_ID()
• Context event(s) before Query event
      – There can be several context events before a Query
• Context event(s) + Query event = Binlog Group
Rand Event: RAND()

• For statements that use RAND() function
       INSERT INTO tbl VALUE (RAND())
• RAND event precedes query
• Hold two seed values used by RAND() on slave


master> SHOW BINLOG EVENTS IN 'mysqld1­bin.000004' FROM 336;
+­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name   | Pos | Event_type | Server_id | End_log_pos | Info                                        |
+­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysqld1... | 336 | RAND       |         1 |         371 | rand_seed1=677022992,rand_seed2=870104260   | 
| mysqld1... | 371 | Query      |         1 |         465 | use `test`; INSERT INTO tbl VALUES (RAND()) | 
+­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
Intvar Event: AUTO_INCREMENT

     • Inserting into an AUTO_INCREMENT column
            INSERT INTO book(title)
                  VALUES(“MySQL High Availability”)
     • Type = INSERT_ID
     • Value = integer


mysql> SHOW BINLOG EVENTS FROM 373;
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info                            |
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql... | 373 | Intvar     |         1 |         401 | INSERT_ID=1                     | 
| mysql... | 401 | Query      |         1 |         522 | use `test`; INSERT INTO book... | 
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
Intvar Event: AUTO_INCREMENT

     • Using LAST_INSERT_ID()
          INSERT INTO author(name, book_id) VALUES
            ('Charles Bell', LAST_INSERT_ID()),
            ('Mats Kindahl', LAST_INSERT_ID()),
            ('Lars Thalmann', LAST_INSERT_ID());
     • Type = LAST_INSERT_ID
     • Value = integer


mysql> SHOW BINLOG EVENTS FROM 522;
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info                            |
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql... | 522 | Intvar     |         1 |         550 | LAST_INSERT_ID=1                | 
| mysql... | 550 | Query      |         1 |         746 | use `test`; INSERT INTO auth... | 
+­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
User_var Event: User-Defined
 Variables
• Using user variable
        SET @LID = LAST_INSERT_ID();
        SET @OReilly = "O'Reilly Media";
        UPDATE book SET publisher = @OReilly
         WHERE id = @LID;
• Typed: STRING, REAL, INT, DECIMAL
mysql> SHOW BINLOG EVENTS FROM 1021;
+­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name | Pos  | Event_type | Serv... | End_log_pos | Info                                          |
+­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql... | 1021 | User var   |       1 |        1048 | @`LID`=1                                      | 
| mysql... | 1048 | User var   |       1 |        1102 | @`Pub`=_latin1 0x4F... COLLATE latin1_swedish | 
| mysql... | 1102 | Query      |       1 |        1217 | use `test`; UPDATE book SET publisher = @P... | 
+­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
3 rows in set (0.00 sec)
Security and the Binary Log
• The replication user with the REPLICATION SLAVE
  privilege can read everything
• You must protect this account from exploitation
• Precautions
   – Prohibit login from outside the firewall
   – Audit the account and place log on a secure location
   – Use encrypted connection (e.g. SSL)
• But... even if you heed these precautions, it isn't
  enough if the data in the binary log is compromised
• Avoid sensitive data in the binary log like passwords
Securing Sensitive Data
• This is bad:
UPDATE employee SET pass = PASSWORD('foobar')
 WHERE email = 'mats@example.com';

• Rewrite the statement to use user-defined variables.
• This is good:
SET @password = PASSWORD('foobar');
UPDATE employee SET pass = @password WHERE email =
'mats@example.com';

• SET statement is not replicated
• No password written to the binary log
Stored Programs

• Stored Procedure     • Logging
  – CREATE PROCEDURE     – Stored Program Definitions?
  – CALL                 – Stored Program Executions?
• Stored Function
  – CREATE FUNCTION
• Triggers
  – CREATE TRIGGER
• Events
  – CREATE EVENT
Stored Procedures Definition

• Always written as        CREATE PROCEDURE add_author(
                             book_id INT,
  statement                  name VARCHAR(64)
• Requires one of          )
                             DETERMINISTIC
  – DETERMINISTIC            SQL SECURITY INVOKER
  – NO SQL                 BEGIN
  – READS SQL DATA           INSERT INTO author
                                VALUES (book_id, name);
• There is no check that   END
  you follow protocol!
Stored Procedure Call

  • Slave execute with privileges off
      – “CALL my_exploit(@@server_id = 1)”
      – Security Issue?
  • Execution is unrolled
      – Actual statements executed are written to binary log
      – Procedure parameters replaced using NAME_CONST

mysql> CALL add_author(1, 'Mats Kindahl');
Query OK, 1 row affected (0.00 sec)

mysql> SHOW BINLOG EVENTS FROM 3457;
+­­­­­­­­­­...­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_name ... | Info                                                                 |
+­­­­­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysqld1­b... | use `test`; INSERT INTO author VALUES ( NAME_CONST('book_id',1), ... | 
+­­­­­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
1 row in set (0.00 sec)
Stored Procedures Definition

• What about definer?                         CREATE PROCEDURE add_author(
    – Statement executed by slave               book_id INT,
                                                name VARCHAR(64)
      thread
                                              )
• User on slave thread?                         DETERMINISTIC
                                                SQL SECURITY DEFINER
    – Not normally
                                              BEGIN
    – Who's definer on slave?                   ...
                                              END
• Rewritten using DEFINER
mysql> SHOW BINLOG EVENTS FROM 3672;
+­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Log_n... | Info                                                                         |
+­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| mysql... | use `test`; CREATE DEFINER=`mats`@`localhost` PROCEDURE `add_author`(... END |
+­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
Triggers and Events

Definitions:
• Similar to stored procedure definitions, trigger and
  event definitions use DEFINER clause
• Event definitions are replicated to the slave as slave-
  side-disabled
  – If you want the replicated events enabled on the slave, you
    need to enable them manually
Execution:
• Event execution effects are replicated
Trigger Execution
CREATE TABLE employee (name VARCHAR(64));
CREATE TABLE log (name VARCHAR(64));
CREATE TRIGGER tr_employee BEFORE UPDATE ON employee
FOR EACH ROW
  INSERT INTO log VALUES
    (CONCAT(OLD.name, “ changed to “, NEW.name))

• What about this statement?
    INSERT INTO employee VALUES (“Chuck”)
• What is in the binary log with respect to the trigger?
  – Nothing
  – Trigger definitions can be different on master and slave
       … even non-existent on master or slave
  – Trigger effects do not have to be replicated
       … because trigger fires on the slave
Stored Function Execution
CREATE FUNCTION get_employee(who VARCHAR(64))
  RETURNS VARCHAR(64)
BEGIN
  DECLARE result VARCHAR(64);
  SELECT name INTO result FROM employee WHERE name = who;
  RETURN result;
END

• Consider this statement
    INSERT INTO authors
      VALUES (get_employee(“Chuck”));
• Statement is logged as entered by user
  – Similar to triggers
  – Definitions can be different on master and slave
Stored Function Execution
CREATE FUNCTION get_employee(who VARCHAR(64))
  RETURNS VARCHAR(64)
  SQL SECURITY INVOKER
BEGIN
  DECLARE result VARCHAR(64);
  IF @@server_id = 1 THEN
    SELECT name INTO result FROM employee WHERE name = who;
  ELSE
    SELECT name INTO result FROM secret_agents LIMIT 1;
  END IF
  RETURN result;
END
• Consider this statement:
    INSERT INTO author
      VALUES (get_employee(“Chuck”));
• Executed without privileges on slave!
  – … and executes different code on master and slave!
• CREATE FUNCTION requires SUPER privileges
    ­­log­bin­trust­function­creators
Replication Architecture
                                                  Mixing InnoDB and MyISAM
Client I                 Client II              changes in the same transaction
                                               can cause slave to be inconsistent
                 MySQL Server                           with the master
                  Master
                             TXN-CACHE
                            TXN-CACHE             •    MyISAM changes are visible
                                                      immediately when statement
                                                                 ends
     Innodb    MyIsam
                                     Binlog   •   Transactional cache is flushed at
                                                            commit time
       Storage Engines
Mixing Engines in Transactions #1

• Non-transactional change outside a
  transaction go directly to binary log
    INSERT INTO myisam VALUES …
    BEGIN;
    INSERT INTO my_innodb VALUES …
       .
       .
       .
    COMMIT;


                                  TRX Cache   Binary Log
Mixing Engines in Transactions #2

• Non-transactional statement goes
  directly to binary log if transaction
  cache is empty
    BEGIN;
    INSERT INTO myisam VALUES …
    INSERT INTO my_innodb VALUES …
       .
       .
       .
    COMMIT;
                                   TRX Cache   Binary Log
Mixing Engines in Transactions #3

• Non-transactional statement goes to
  transaction cache if not empty
     BEGIN;
     INSERT INTO my_innodb VALUES …
     INSERT INTO myisam VALUES …
        .
        .
        .
     COMMIT;


         5                         TRX Cache   Binary Log
      5.
  SQL
My --binlog-direct-non-transactional-changes
Mixing Engines in Transactions #4

• Rollback writes transaction cache to
  binary log if it contains any non-
  transactional changes
    BEGIN;
    INSERT INTO my_innodb VALUES …
    INSERT INTO myisam VALUES …
       .
       .
       .
    ROLLBACK;
                                  TRX Cache   Binary Log
Mixing Engines in Transactions #5

• Rollback clears transaction cache if it
  contains only transactional changes
    BEGIN;
    INSERT INTO my_innodb VALUES …
       .
       .
       .
    ROLLBACK;


                                    TRX Cache   Binary Log
Mixing Engines in Statements
CREATE TABLE employee (name VARCHAR(64)) ENGINE=InnoDB;
CREATE TABLE log (name VARCHAR(64)) ENGINE=MyISAM;
CREATE TRIGGER tr_employee BEFORE UPDATE ON employee
FOR EACH ROW
  INSERT INTO log VALUES
    (CONCAT(OLD.name, “ changed to “, NEW.name))




• What about this statement?
    UPDATE employee SET name = “Charles”
     WHERE name = “Chuck”;
• Transactional or non-transactional?
  – If a statement contain any non-transactional changes, it is
    considered non-transactional
Mixing Transactional and Non-
  transactional statements
• You can do this, but it has consequences
• Considerations
    – Non-transactional statements inside the transaction are committed
      implicitly – and written to the binary log
    – If the transactional statements fail, they are not written to the binary
      log
• Implicit commits
  – CREATE, ALTER
  – Modifications to mysql database (post 5.1.3)
  – Pragmatic causes (e.g., LOAD DATA INFILE)
• Avoiding the problem
    – Place non-transactional statements first
    – If you need values from these statements, use temporary tables or
      variables
Buy this book!
  Questions?



Coming soon:
 June 2010




                  Buy the book!

Contenu connexe

Tendances

Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Mydbops
 
Making Nested Columns as First Citizen in Apache Spark SQL
Making Nested Columns as First Citizen in Apache Spark SQLMaking Nested Columns as First Citizen in Apache Spark SQL
Making Nested Columns as First Citizen in Apache Spark SQLDatabricks
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the RoadmapEDB
 
InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)I Goo Lee.
 
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PGPgDay.Seoul
 
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLJim Mlodgenski
 
Tuning Autovacuum in Postgresql
Tuning Autovacuum in PostgresqlTuning Autovacuum in Postgresql
Tuning Autovacuum in PostgresqlMydbops
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides Altinity Ltd
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
Materialized Column: An Efficient Way to Optimize Queries on Nested Columns
Materialized Column: An Efficient Way to Optimize Queries on Nested ColumnsMaterialized Column: An Efficient Way to Optimize Queries on Nested Columns
Materialized Column: An Efficient Way to Optimize Queries on Nested ColumnsDatabricks
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBrendan Gregg
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyAlexander Kukushkin
 
MySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMarco Tusa
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLMorgan Tocker
 
Kernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringKernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringAnne Nicolas
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스PgDay.Seoul
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep InternalEXEM
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenPostgresOpen
 

Tendances (20)

Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 
Making Nested Columns as First Citizen in Apache Spark SQL
Making Nested Columns as First Citizen in Apache Spark SQLMaking Nested Columns as First Citizen in Apache Spark SQL
Making Nested Columns as First Citizen in Apache Spark SQL
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
 
InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)
 
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG[Pgday.Seoul 2018]  이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
[Pgday.Seoul 2018] 이기종 DB에서 PostgreSQL로의 Migration을 위한 DB2PG
 
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
 
Tuning Autovacuum in Postgresql
Tuning Autovacuum in PostgresqlTuning Autovacuum in Postgresql
Tuning Autovacuum in Postgresql
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
Materialized Column: An Efficient Way to Optimize Queries on Nested Columns
Materialized Column: An Efficient Way to Optimize Queries on Nested ColumnsMaterialized Column: An Efficient Way to Optimize Queries on Nested Columns
Materialized Column: An Efficient Way to Optimize Queries on Nested Columns
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame Graphs
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
 
MySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMySQL innoDB split and merge pages
MySQL innoDB split and merge pages
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
Kernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringKernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uring
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
 

Similaire à Mysteries of the binary log

Using Archivematica 0.8 for Digitized Content
Using Archivematica 0.8 for Digitized ContentUsing Archivematica 0.8 for Digitized Content
Using Archivematica 0.8 for Digitized Contentsbigelow
 
MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores Mydbops
 
InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)Ontico
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011Mats Kindahl
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structureZhichao Liang
 
MySQL & noSQL Conference: MySQL for Sysadmins
MySQL & noSQL Conference: MySQL for SysadminsMySQL & noSQL Conference: MySQL for Sysadmins
MySQL & noSQL Conference: MySQL for SysadminsJavier Tomas Zon
 
Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets  Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets Perforce
 
Innodb 和 XtraDB 结构和性能优化
Innodb 和 XtraDB 结构和性能优化Innodb 和 XtraDB 结构和性能优化
Innodb 和 XtraDB 结构和性能优化YUCHENG HU
 
Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...Alluxio, Inc.
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishFlorent Pillet
 
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of GitGit Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of GitNicola Costantino
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentKarthik .P.R
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentRemote MySQL DBA
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsNelson Calero
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the starsStrannik_2013
 
Rman Presentation
Rman PresentationRman Presentation
Rman PresentationRick van Ek
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevFuenteovejuna
 

Similaire à Mysteries of the binary log (20)

Using Archivematica 0.8 for Digitized Content
Using Archivematica 0.8 for Digitized ContentUsing Archivematica 0.8 for Digitized Content
Using Archivematica 0.8 for Digitized Content
 
MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores
 
InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structure
 
MySQL & noSQL Conference: MySQL for Sysadmins
MySQL & noSQL Conference: MySQL for SysadminsMySQL & noSQL Conference: MySQL for Sysadmins
MySQL & noSQL Conference: MySQL for Sysadmins
 
Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets  Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets
 
Azure storage
Azure storageAzure storage
Azure storage
 
Innodb 和 XtraDB 结构和性能优化
Innodb 和 XtraDB 结构和性能优化Innodb 和 XtraDB 结构和性能优化
Innodb 和 XtraDB 结构和性能优化
 
Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - English
 
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of GitGit Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
 
Oracle DB
Oracle DBOracle DB
Oracle DB
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
 
Rman Presentation
Rman PresentationRman Presentation
Rman Presentation
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter Zaitsev
 

Plus de Mats Kindahl

Building Scalable High Availability Systems using MySQL Fabric
Building Scalable High Availability Systems using MySQL FabricBuilding Scalable High Availability Systems using MySQL Fabric
Building Scalable High Availability Systems using MySQL FabricMats Kindahl
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL FabricMats Kindahl
 
Elastic Scalability in MySQL Fabric Using OpenStack
Elastic Scalability in MySQL Fabric Using OpenStackElastic Scalability in MySQL Fabric Using OpenStack
Elastic Scalability in MySQL Fabric Using OpenStackMats Kindahl
 
Sharding and Scale-out using MySQL Fabric
Sharding and Scale-out using MySQL FabricSharding and Scale-out using MySQL Fabric
Sharding and Scale-out using MySQL FabricMats Kindahl
 
MySQL Fabric: Easy Management of MySQL Servers
MySQL Fabric: Easy Management of MySQL ServersMySQL Fabric: Easy Management of MySQL Servers
MySQL Fabric: Easy Management of MySQL ServersMats Kindahl
 
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFS
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFSMySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFS
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFSMats Kindahl
 
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMats Kindahl
 
Replication Tips & Trick for SMUG
Replication Tips & Trick for SMUGReplication Tips & Trick for SMUG
Replication Tips & Trick for SMUGMats Kindahl
 
Sharding using MySQL and PHP
Sharding using MySQL and PHPSharding using MySQL and PHP
Sharding using MySQL and PHPMats Kindahl
 
Replication Tips & Tricks
Replication Tips & TricksReplication Tips & Tricks
Replication Tips & TricksMats Kindahl
 
Python Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesPython Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesMats Kindahl
 

Plus de Mats Kindahl (12)

Why rust?
Why rust?Why rust?
Why rust?
 
Building Scalable High Availability Systems using MySQL Fabric
Building Scalable High Availability Systems using MySQL FabricBuilding Scalable High Availability Systems using MySQL Fabric
Building Scalable High Availability Systems using MySQL Fabric
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL Fabric
 
Elastic Scalability in MySQL Fabric Using OpenStack
Elastic Scalability in MySQL Fabric Using OpenStackElastic Scalability in MySQL Fabric Using OpenStack
Elastic Scalability in MySQL Fabric Using OpenStack
 
Sharding and Scale-out using MySQL Fabric
Sharding and Scale-out using MySQL FabricSharding and Scale-out using MySQL Fabric
Sharding and Scale-out using MySQL Fabric
 
MySQL Fabric: Easy Management of MySQL Servers
MySQL Fabric: Easy Management of MySQL ServersMySQL Fabric: Easy Management of MySQL Servers
MySQL Fabric: Easy Management of MySQL Servers
 
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFS
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFSMySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFS
MySQL Applier for Apache Hadoop: Real-Time Event Streaming to HDFS
 
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
 
Replication Tips & Trick for SMUG
Replication Tips & Trick for SMUGReplication Tips & Trick for SMUG
Replication Tips & Trick for SMUG
 
Sharding using MySQL and PHP
Sharding using MySQL and PHPSharding using MySQL and PHP
Sharding using MySQL and PHP
 
Replication Tips & Tricks
Replication Tips & TricksReplication Tips & Tricks
Replication Tips & Tricks
 
Python Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesPython Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL Databases
 

Dernier

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Dernier (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Mysteries of the binary log

  • 1. <Insert Picture Here> Mysteries of the Binary Log Mats Kindahl Charles Bell Lead Replication Developer Lead Backup Developer
  • 2. About the Speakers Mats Kindahl, PhD • • Replication Expert and Lead Developer • mats.kindahl@sun.com Chuck Bell, PhD • • Enterprise Backup and Replication • chuck.bell@oracle.com Lars Thalmann, PhD • • Development Manager, Replication and Backup • lars.thalmann@sun.com
  • 3. What is the binary log? • Record of changes Master Slave • Used for – Replication – Auditing – Point-In-Time Recovery (PITR) • Slave executes changes with privileges turned off – Security implications? – “If it is OK to execute on the master, it should be OK to execute on the slave” – Not always true (as you will see)
  • 4. Best Practices • Manage your log rotations • Protect your logs – Store on secure location – Don't store on same disk as data • Purge old logs – PURGE command – --expire-log-days • Use log filters sparingly if point-in-time recovery a priority • Protect the replication user account from tampering • Avoid using sensitive data in statements (e.g. passwords)
  • 5. Structure of the Binary Log Binlog files • Option log­bin Binary Log • Default master­bin.000001 master-bin.000001 master-bin.000002 • Content of binary log master-bin.000003 Binlog index • Option log­bin­index • Default master­bin.index Binlog files Index file • Index over binlog files
  • 6. Binlog file structure • Format Description Event – File-specific data Groups – Binlog Format Version Format Description INSERT INTO tbl VALUES ... – Server Version BEGIN; UPDATE tbl SET passwd = ... • Rotate UPDATE account SET value... COMMIT; – Terminate binlog file – Next file in sequence • Binlog Events – Organized in groups Rotate – MySQL 5.1 have 26 different event types
  • 7. Binlog file structure • Binary Log Coordinate mysql­bin.000001 – File name Groups – File position Format Description INSERT INTO tbl VALUES ... BEGIN; UPDATE tbl SET passwd = ... UPDATE account SET value... COMMIT; Rotate
  • 8. Investigating Binary Log • SHOW BINLOG EVENTS – IN file – FROM position – LIMIT events • Shows contents of first binlog file (!) – Not contents of last binlog file mysql> SHOW BINLOG EVENTS; +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                             | +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql­bin.000001 |   4 | Format_desc |         1 |         106 | Server ver: 5.1.37­1ubuntu5.1­log, Binlog ver: 4 |  | mysql­bin.000001 | 106 | Query       |         1 |         250 | use `test`; CREATE TABLE book (id INT UNSIGNE... |  | mysql­bin.000001 | 250 | Query       |         1 |         373 | use `test`; CREATE TABLE author (name VARCHAR... |  +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 3 rows in set (0.00 sec) Size = End_log_pos - Pos
  • 9. Purging Binlog Files • PURGE BINARY LOG TO filename Deletes all binary log files before the named file. • PURGE BINARY LOG BEFORE datetime Purge will always delete complete files. This means that if there is at least one event in the log file that has a time stamp after datetime, the file is not deleted. • RESET MASTER – Deletes all binary log files listed in the index file, resets the index, and creates a new binlog file.
  • 10. Purging Binlog Files • Automatically purge logs – Server_variable: expire_logs_days – Removes the binlog files that are at least that old – The removal happens at server start or log flush
  • 11. Binlog Event Structure • Common header • Generic data Common Header • Fixed size • Post-header Post-header • Event-specific data • Fixed size • Variable part • Event-specific data Variable Part • Variable size
  • 12. Binlog Event Common Header • Data common to all events Timestamp Type Server ID • File Position 4 bytes – End of event • Timestamp – Statement start time • Flags – Binlog-in-use – Thread-specific File Position – Suppress “use” Length – Artificial Flags 19 Bytes – Relay-log event
  • 13. Format Description Event Common Header Binlog Format Version • Describes file information Server Version – Different files can have (50 bytes) different information Common Header Length – Design for extensibility Post-header • Common header length Lengths • Post-header lengths Creation Time • Fixed size! mysql> SHOW BINLOG EVENTS; +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                             | +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql­bin.000001 |   4 | Format_desc |         1 |         106 | Server ver: 5.1.37­1ubuntu5.1­log, Binlog ver: 4 |  | mysql­bin.000001 | 106 | Query       |         1 |         250 | use `test`; CREATE TABLE book (id INT UNSIGNE... |  | mysql­bin.000001 | 250 | Query       |         1 |         373 | use `test`; CREATE TABLE author (name VARCHAR... |  +­­­­­­­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 3 rows in set (0.00 sec)
  • 14. Query Event Thread ID Execution Time • Most common event • Used for statements Common Header Status Variable Statement logged literally • Code – … in almost all cases Query Status Variable Value Db Length Error Code Status Variables Length
  • 15. Handling Statement Context • SQL_MODE • Time functions – NOW(), CURDATE(), CURTIME(), UNIX_TIMESTAMP() – SYSDATE() • Auto-increment handling – Insert into AUTO_INCREMENT column – Using LAST_INSERT_ID() – @@auto_increment_increment – @@auto_increment_offset • User-defined variables • Seed for RAND() • Character set
  • 16. Status Variables • Added in query event • SQL_MODE – Only when needed • Catalog • auto_increment_increment • auto_increment_offset • Character Set • Time Zone
  • 17. Time Functions • Execution start time is saved for session – Recorded in binlog event • Some functions use statement start time – NOW(), CURTIME(), CURDATE(), UNIX_TIMESTAMP()OK • Some functions call time(2) directly g ! nin – SYSDATE() ar W
  • 18. Context Events • Context events are used for: • User-defined variables • RAND() seeds • AUTO_INCREMENT • LAST_INSERT_ID() • Context event(s) before Query event – There can be several context events before a Query • Context event(s) + Query event = Binlog Group
  • 19. Rand Event: RAND() • For statements that use RAND() function INSERT INTO tbl VALUE (RAND()) • RAND event precedes query • Hold two seed values used by RAND() on slave master> SHOW BINLOG EVENTS IN 'mysqld1­bin.000004' FROM 336; +­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name   | Pos | Event_type | Server_id | End_log_pos | Info                                        | +­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysqld1... | 336 | RAND       |         1 |         371 | rand_seed1=677022992,rand_seed2=870104260   |  | mysqld1... | 371 | Query      |         1 |         465 | use `test`; INSERT INTO tbl VALUES (RAND()) |  +­­­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec)
  • 20. Intvar Event: AUTO_INCREMENT • Inserting into an AUTO_INCREMENT column INSERT INTO book(title)       VALUES(“MySQL High Availability”) • Type = INSERT_ID • Value = integer mysql> SHOW BINLOG EVENTS FROM 373; +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info                            | +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql... | 373 | Intvar     |         1 |         401 | INSERT_ID=1                     |  | mysql... | 401 | Query      |         1 |         522 | use `test`; INSERT INTO book... |  +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec)
  • 21. Intvar Event: AUTO_INCREMENT • Using LAST_INSERT_ID() INSERT INTO author(name, book_id) VALUES   ('Charles Bell', LAST_INSERT_ID()),   ('Mats Kindahl', LAST_INSERT_ID()),   ('Lars Thalmann', LAST_INSERT_ID()); • Type = LAST_INSERT_ID • Value = integer mysql> SHOW BINLOG EVENTS FROM 522; +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info                            | +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql... | 522 | Intvar     |         1 |         550 | LAST_INSERT_ID=1                |  | mysql... | 550 | Query      |         1 |         746 | use `test`; INSERT INTO auth... |  +­­­­­­­­­­+­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec)
  • 22. User_var Event: User-Defined Variables • Using user variable SET @LID = LAST_INSERT_ID(); SET @OReilly = "O'Reilly Media"; UPDATE book SET publisher = @OReilly  WHERE id = @LID; • Typed: STRING, REAL, INT, DECIMAL mysql> SHOW BINLOG EVENTS FROM 1021; +­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name | Pos  | Event_type | Serv... | End_log_pos | Info                                          | +­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql... | 1021 | User var   |       1 |        1048 | @`LID`=1                                      |  | mysql... | 1048 | User var   |       1 |        1102 | @`Pub`=_latin1 0x4F... COLLATE latin1_swedish |  | mysql... | 1102 | Query      |       1 |        1217 | use `test`; UPDATE book SET publisher = @P... |  +­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­+­­­­­­­­­+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 3 rows in set (0.00 sec)
  • 23. Security and the Binary Log • The replication user with the REPLICATION SLAVE privilege can read everything • You must protect this account from exploitation • Precautions – Prohibit login from outside the firewall – Audit the account and place log on a secure location – Use encrypted connection (e.g. SSL) • But... even if you heed these precautions, it isn't enough if the data in the binary log is compromised • Avoid sensitive data in the binary log like passwords
  • 24. Securing Sensitive Data • This is bad: UPDATE employee SET pass = PASSWORD('foobar') WHERE email = 'mats@example.com'; • Rewrite the statement to use user-defined variables. • This is good: SET @password = PASSWORD('foobar'); UPDATE employee SET pass = @password WHERE email = 'mats@example.com'; • SET statement is not replicated • No password written to the binary log
  • 25. Stored Programs • Stored Procedure • Logging – CREATE PROCEDURE – Stored Program Definitions? – CALL – Stored Program Executions? • Stored Function – CREATE FUNCTION • Triggers – CREATE TRIGGER • Events – CREATE EVENT
  • 26. Stored Procedures Definition • Always written as CREATE PROCEDURE add_author(   book_id INT, statement   name VARCHAR(64) • Requires one of )   DETERMINISTIC – DETERMINISTIC   SQL SECURITY INVOKER – NO SQL BEGIN – READS SQL DATA   INSERT INTO author      VALUES (book_id, name); • There is no check that END you follow protocol!
  • 27. Stored Procedure Call • Slave execute with privileges off – “CALL my_exploit(@@server_id = 1)” – Security Issue? • Execution is unrolled – Actual statements executed are written to binary log – Procedure parameters replaced using NAME_CONST mysql> CALL add_author(1, 'Mats Kindahl'); Query OK, 1 row affected (0.00 sec) mysql> SHOW BINLOG EVENTS FROM 3457; +­­­­­­­­­­...­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_name ... | Info                                                                 | +­­­­­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysqld1­b... | use `test`; INSERT INTO author VALUES ( NAME_CONST('book_id',1), ... |  +­­­­­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 1 row in set (0.00 sec)
  • 28. Stored Procedures Definition • What about definer? CREATE PROCEDURE add_author( – Statement executed by slave   book_id INT,   name VARCHAR(64) thread ) • User on slave thread?   DETERMINISTIC   SQL SECURITY DEFINER – Not normally BEGIN – Who's definer on slave?   ... END • Rewritten using DEFINER mysql> SHOW BINLOG EVENTS FROM 3672; +­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Log_n... | Info                                                                         | +­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | mysql... | use `test`; CREATE DEFINER=`mats`@`localhost` PROCEDURE `add_author`(... END | +­­­­­­...­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec)
  • 29. Triggers and Events Definitions: • Similar to stored procedure definitions, trigger and event definitions use DEFINER clause • Event definitions are replicated to the slave as slave- side-disabled – If you want the replicated events enabled on the slave, you need to enable them manually Execution: • Event execution effects are replicated
  • 30. Trigger Execution CREATE TABLE employee (name VARCHAR(64)); CREATE TABLE log (name VARCHAR(64)); CREATE TRIGGER tr_employee BEFORE UPDATE ON employee FOR EACH ROW   INSERT INTO log VALUES     (CONCAT(OLD.name, “ changed to “, NEW.name)) • What about this statement? INSERT INTO employee VALUES (“Chuck”) • What is in the binary log with respect to the trigger? – Nothing – Trigger definitions can be different on master and slave … even non-existent on master or slave – Trigger effects do not have to be replicated … because trigger fires on the slave
  • 31. Stored Function Execution CREATE FUNCTION get_employee(who VARCHAR(64))   RETURNS VARCHAR(64) BEGIN   DECLARE result VARCHAR(64);   SELECT name INTO result FROM employee WHERE name = who;   RETURN result; END • Consider this statement INSERT INTO authors   VALUES (get_employee(“Chuck”)); • Statement is logged as entered by user – Similar to triggers – Definitions can be different on master and slave
  • 32. Stored Function Execution CREATE FUNCTION get_employee(who VARCHAR(64))   RETURNS VARCHAR(64)   SQL SECURITY INVOKER BEGIN   DECLARE result VARCHAR(64);   IF @@server_id = 1 THEN     SELECT name INTO result FROM employee WHERE name = who;   ELSE     SELECT name INTO result FROM secret_agents LIMIT 1;   END IF   RETURN result; END • Consider this statement: INSERT INTO author   VALUES (get_employee(“Chuck”)); • Executed without privileges on slave! – … and executes different code on master and slave! • CREATE FUNCTION requires SUPER privileges ­­log­bin­trust­function­creators
  • 33. Replication Architecture Mixing InnoDB and MyISAM Client I Client II changes in the same transaction can cause slave to be inconsistent MySQL Server with the master Master TXN-CACHE TXN-CACHE • MyISAM changes are visible immediately when statement ends Innodb MyIsam Binlog • Transactional cache is flushed at commit time Storage Engines
  • 34. Mixing Engines in Transactions #1 • Non-transactional change outside a transaction go directly to binary log INSERT INTO myisam VALUES … BEGIN; INSERT INTO my_innodb VALUES …    .    .    . COMMIT; TRX Cache Binary Log
  • 35. Mixing Engines in Transactions #2 • Non-transactional statement goes directly to binary log if transaction cache is empty BEGIN; INSERT INTO myisam VALUES … INSERT INTO my_innodb VALUES …    .    .    . COMMIT; TRX Cache Binary Log
  • 36. Mixing Engines in Transactions #3 • Non-transactional statement goes to transaction cache if not empty BEGIN; INSERT INTO my_innodb VALUES … INSERT INTO myisam VALUES …    .    .    . COMMIT; 5 TRX Cache Binary Log 5. SQL My --binlog-direct-non-transactional-changes
  • 37. Mixing Engines in Transactions #4 • Rollback writes transaction cache to binary log if it contains any non- transactional changes BEGIN; INSERT INTO my_innodb VALUES … INSERT INTO myisam VALUES …    .    .    . ROLLBACK; TRX Cache Binary Log
  • 38. Mixing Engines in Transactions #5 • Rollback clears transaction cache if it contains only transactional changes BEGIN; INSERT INTO my_innodb VALUES …    .    .    . ROLLBACK; TRX Cache Binary Log
  • 39. Mixing Engines in Statements CREATE TABLE employee (name VARCHAR(64)) ENGINE=InnoDB; CREATE TABLE log (name VARCHAR(64)) ENGINE=MyISAM; CREATE TRIGGER tr_employee BEFORE UPDATE ON employee FOR EACH ROW   INSERT INTO log VALUES     (CONCAT(OLD.name, “ changed to “, NEW.name)) • What about this statement? UPDATE employee SET name = “Charles”  WHERE name = “Chuck”; • Transactional or non-transactional? – If a statement contain any non-transactional changes, it is considered non-transactional
  • 40. Mixing Transactional and Non- transactional statements • You can do this, but it has consequences • Considerations – Non-transactional statements inside the transaction are committed implicitly – and written to the binary log – If the transactional statements fail, they are not written to the binary log • Implicit commits – CREATE, ALTER – Modifications to mysql database (post 5.1.3) – Pragmatic causes (e.g., LOAD DATA INFILE) • Avoiding the problem – Place non-transactional statements first – If you need values from these statements, use temporary tables or variables
  • 41. Buy this book! Questions? Coming soon: June 2010 Buy the book!