Time stamp conflict resolution rule
The time stamp rule evaluates the latest time stamp of the replication against the target and determines how to resolve any conflict.
All time stamps and internal computations are performed in Greenwich mean time (GMT). The time stamp conflict resolution rule assumes time synchronization between cooperating Enterprise Replication servers.
- Row scope
Enterprise Replication evaluates one row at a time. The row with the most recent time stamp wins the conflict and is applied to the target database servers. If an SPL routine is defined as a secondary conflict-resolution rule, the routine resolves the conflict when the row times are equal.
- Transaction scope
Enterprise Replication evaluates the most recent row-update time among all the rows in the replicated transaction. This time is compared to the time stamp of the appropriate target row. If the time stamp of the replicated row is more recent than the target, the entire replicated transaction is applied. If a routine is defined as a secondary conflict resolution rule, it is used to resolve the conflict when the time stamps are equal.
A secondary routine is run only if Enterprise Replication evaluates rows and discovers equal time stamps.
If no secondary conflict-resolution rule is defined and the time stamps are equal, the transaction from the database server with the lower value in the cdrserver shadow column wins the conflict.
The following table shows how a conflict is resolved based on the latest time stamp with row scope. The time stamp Tlast_update (the time of the last update) represents the row on the target database server with the last (most recent) update. The time stamp Trepl (the time when replication occurs) represents the time stamp on the incoming row.
Enterprise Replication first checks to see whether a row with the same replication key exists in either the target table or its corresponding delete table.
If the row exists, Enterprise Replication uses the latest time stamp to resolve the conflict.
The following table describes how the time stamp conflict resolution rule handles INSERT, UPDATE, and DELETE operations.
Row Exists on Target? | Time Stamp | INSERT | UPDATE | DELETE |
---|---|---|---|---|
No | n/a | Apply row | Apply row (Convert UPDATE to INSERT) | Apply row (INSERT into Enterprise Replication delete table) |
Yes | Tlast_update < Trepl | Apply row (Convert INSERT to UPDATE) | Apply row | Apply row |
Yes | Tlast_update > Trepl | Discard row | Discard row | Discard row |
Yes | Tlast_update = Trepl | Apply row if no routine is defined as a secondary conflict resolution rule. Otherwise, run the routine. | Apply row if no routine is defined as a secondary conflict resolution rule. Otherwise, run the routine. | Apply row if no routine is defined as a secondary conflict resolution rule. Otherwise, run the routine. |
To use time stamp conflict resolution for repairing inconsistencies with the cdr check replicate or cdr check replicateset command, include the --timestamp option with the --repair option. If you temporarily stop replication on a server whose replicates use the time stamp conflict resolution rule, disable the replication server with the cdr disable server command. When you disable a server, information about deleted rows is kept in the delete tables to be used during the time stamp repair after the server is enabled.