Snapshot and Synchronization Overview v6.2
xDB Replication Server performs two different types of replications. These two main types are called snapshot replication and synchronization replication.
In either method, the source tables refer to the tables from which the replication data is originating (the publication in a single-master replication system, or the primary node whose changes are being replicated to another primary node in a multi-master replication system).
The target tables are the tables that are receiving the replication data from the source tables (the subscription tables in a single-master replication system, or the primary node receiving changes from another primary node in a multi-master replication system).
In snapshot replication, all existing rows in the target tables are deleted using the database system’s
TRUNCATE command. The tables are then completely reloaded from the source tables of the publication.
In synchronization replication, only the changes (inserts, updates, and deletions) to the rows in the source tables since the last replication are applied to the target tables.
Deletion of all rows in a source table executed by the
SQL TRUNCATE command results in replication to the target tables only if the log-based method of synchronization replication is used. If the trigger-based method of synchronization replication is used, execution of the
TRUNCATE command on a source table does not replicate the effect to the target tables. You must perform a snapshot from the source table to the target tables if the trigger-based method is used. (The difference between the trigger-based method and the log-based method is discussed as follows.)
Synchronization replication is implemented using two different methods – the trigger-based method and the log-based method.
In the trigger-based method changes to rows in the source tables result in the firing of row-based triggers. These triggers record the changes in shadow tables. The changes recorded in the shadow tables are then periodically extracted from the shadow tables, converted to an in-memory data structure, and applied to the target tables by means of SQL statements executed using JDBC. See Synchronization Replication with the Trigger-Based Method for information on the trigger-based method.
In the log-based method changes to rows in the source tables are extracted from the Write-Ahead Log segments (WAL files) using asynchronous streaming replication implemented by the logical decoding feature available in Postgres database servers. The extracted changes are converted to an in-memory data structure and applied to the target tables by means of SQL statements executed using JDBC. See Synchronization Replication with the Log-Based Method for information on the log-based method.
In a multi-master replication system, the manner in which changes accumulated on all primary nodes are replicated to all other primary nodes is conceptually done in groups identified by the source primary node with the changes to be replicated. See Multi-Master Parallel Replication for information on this process and the improvement for the log-based method with parallel replication.
In a single-master replication system, the very first replication to a newly created subscription must always be done by a snapshot. Subsequent replications can be done by snapshot or by synchronization provided that the publication is not defined as a snapshot-only publication as discussed in Snapshot-Only Publications.
In a multi-master replication system, the very first replication from the primary definition node to a newly added primary node must always be done by a snapshot. Subsequent replications between primary nodes occur by synchronization. However, it is possible to perform subsequent snapshots from the primary definition node to any other primary node.