Docsity

Database replication, Summaries of Technology

Partial preview of the text

Download Database replication and more Summaries Technology in PDF only on Docsity!

MySQL Replication vs Galera: which is better for your workload?

Nickolay Ihalainen (Percona)

Replication is better than standalone

  • Standalone
  • Less parts leading to less faults
  • New transactions reading committed data instantly
  • You know where to find a database

Statement (SQL) replication

  • Non-deterministic queries crashing replication โˆ’ UUID(), RAND() โˆ’ DELETE/UPDATE + LIMIT ะฑะตะท ORDER BY
  • READ COMMITTED / READ UNCOMMITTED

ROW based replication

  • How to find a row? โˆ’ Primary Key!
  • What to transfer? โˆ’ row before โˆ’ row after โˆ’ partial row

Replication: faults

  • semi-sync โˆ’ Does the slave receive replication event? โˆ’ COMMIT waits for the confirmation from at least single slave โ— rpl_semi_sync_master_wait_for_slave_count
  • crash-safe slave (default 8.0) โˆ’ relay-log-info-repository=TABLE โˆ’ relay-log-recovery=ON

Replication: group commit

  • InnoDB => MySQL: Transaction is ready! โˆ’ PREPARE โˆ’ multiple transactions committed in parallel
  • MySQL => InnoDB: binlog fsync finished
  • binlog_group_commit_sync_delay
  • binlog_group_commit_sync_no_delay_count

Replication: WRITESET

  • Replication event: โˆ’ db.table.PK โˆ’ row
  • For each row calculate XXHASH64(PK)
  • Foreign keys are not supported

Parallel slave

  • slave_parallel_type โˆ’ DATABASE โˆ’ LOGICAL_CLOCK
  • binlog_transaction_dependency_tracking โˆ’ COMMIT_ORDER โˆ’ WRITESET, WRITESET_SESSION

Group Replication

  • New network protocol โˆ’ eXtended COMmunication
  • cluster members state monitoring
  • single-primary, multi-primary โˆ’ primary role switchover

Group Replication: XCom

  • Based on Paxos (Mencius)
  • Strict transaction commit order in cluster
  • Dynamic membership
  • Fault detection

Multi-Paxos

  • Elect the leader only once
  • Skip elections (prepare )
  • Leader proxies messages

Mencius

  • Every node has a leader slot
  • nothing to suggest? โˆ’ send a SKIP

XCom: restrictions

  • up to 9 nodes
  • long message processing? Node evicted from cluster โˆ’ group_replication_member_expel_timeout = 5 seconds โˆ’ group_replication_transaction_size_limit = 143MB โˆ’ group_replication_communication_max_message_size = 10MB

Group Repl.: Single Primary

  • Better than async replication! โˆ’ automatic recovery after fault โˆ’ guarantees the same row values on all nodes