Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When the barrier batch is encountered during append or during log recovery, all producer entries are removed from the PSM. This ensures leaders, followers, and recovery all handle the barrier consistently. Because the partition is read-only during mirroring, all PSM entries originate from mirrored data. Expiring all entries is safe: no local producer state exists to preserve. Control batches are filtered out by the consumer fetcher via isControlBatch checks. The barrier is invisible to application consumers, just like transaction markers (commit/abort). The log dump tool is enhanced to deserialize and display MIRROR_PID_RESET records.

Chaining example

Code Block
A             B             C
5(A) -------> 5(A) -------> 5(A) # 5(A) means PID:5, source cluster:A
              CB   -------> CB   # Control Batch appended when A failover to B
              5(B) -------> 5(B) # In B and C, even if 2 records with PID 5, they won't duplicate with each other because of the control batch.

Supported Topologies

The barrier approach works correctly with all practical mirroring topologies:                                                                                                                                                                                                            

  • Active-passive (A to B): B mirrors from A, stores records as-is. On failover, barrier expires all PSM entries. Local producers get fresh PIDs from the coordinator with no collision risk.                                                                                            
  • Failback (A to B, then B to A): After failover, B becomes writable. Later, A starts mirroring from B and truncates its log to the LSO. A then stores B's records as-is. B's barrier record is included in the fetched data and appended to A's log, triggering PSM expiration on A. This is consistent with the general rule: when the barrier batch is encountered during append or during log recovery, all producer entries are removed from the PSM. A will write its own barrier when it eventually stops mirroring from B, producing a clean slate before A becomes writable again.

  • Fan-out (A to B, A to C): B and C mirror independently from A, each with its own PSM per partition. On failover, each writes its own barrier independently.
  • Fan-in (A to C, B to C, different topics): Each topic's partitions have independent PSMs. The barrier is written per partition during the STOPPING transition of each mirror.
  • Chain (A to B to C): B mirrors from A, stores records as-is. C mirrors from B, stores records as-is. On failover at any point in the chain, the barrier expires all PSM entries on the stopping node. Longer chains work inductively by the same principle.

Chaining example

Code Block
A             B             C
5(A) -------> 5(A) -------> 5(A) # 5(A) means PID:5, source cluster:A
              CB   -------> CB   # Control Batch appended when A failover to B
              5(B) -------> 5(B) # In B and C, even if 2 records with PID 5, they won't duplicate with each other because of the control batch.