Skip to content

Conversation

@ibrarahmad
Copy link
Contributor

Implement preserve-origin feature that maintains original replication origin node ID and timstamp when repairing rows during recovery scenarios. This prevents replication conflicts when the origin node returns to the cluster.

Test Scenario

  • Source Node: n3 (has 70 rows with origin_id=49708, timestamp=2026-01-15 21:17:31)
  • Target Node: n2 (initially empty, needs recovery)
  • Test Rows: IDs 21-25 (sample of 10 recovered rows)
  • Original Origin: node_n1 (origin_id=49708 on n3)
Test Case Row ID Source Timestamp Source Origin Recovered Timestamp Recovered Origin Timestamp Preserved Origin Preserved Both Preserved
WITHOUT Patch
(no --preserve-origin)
21 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:29:XX+05 NULL/different NO NO NO
22 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:29:XX+05 NULL/different NO NO NO
23 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:29:XX+05 NULL/different NO NO NO
24 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:29:XX+05 NULL/different NO NO NO
25 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:29:XX+05 NULL/different NO NO NO
WITH Patch
(--preserve-origin)
21 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:17:31+05 node_n1 YES YES YES
22 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:17:31+05 node_n1 YES YES YES
23 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:17:31+05 node_n1 YES YES YES
24 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:17:31+05 node_n1 YES YES YES
25 2026-01-15 21:17:31+05 node_n1 2026-01-15 21:17:31+05 node_n1 YES YES YES

Implement preserve-origin feature that maintains original replication origin
node ID and LSN when repairing rows during recovery scenarios. This prevents
replication conflicts when the origin node returns to the cluster.
Copy link
Member

@mason-sharp mason-sharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments.

Also, please add tests.

Ibrar Ahmed added 2 commits February 2, 2026 18:15
Enhances the preserve-origin feature to maintain per-row timestamp accuracy
during table repairs. Each unique timestamp now gets its own transaction,
ensuring rows maintain their original commit timestamps with microsecond
precision. This is critical for temporal ordering and conflict resolution in
distributed database recovery scenarios.

Key changes: refactored grouping to use (origin, LSN, timestamp) tuples,
implemented per-timestamp transaction management, changed timestamp format
from RFC3339 to RFC3339Nano for microsecond precision, added unit tests for
batch key functions, and moved replication origin resets after commit.
Enhances preserve-origin documentation to describe how each unique timestamp
gets its own transaction for microsecond-precision preservation. Critical for
temporal ordering and conflict resolution in recovery scenarios.

Key changes: added preserve-origin flag to API docs, expanded table-repair
command documentation with per-row timestamp details, and updated HTTP API
documentation with behavior notes.
@ibrarahmad
Copy link
Contributor Author

A couple of comments.

Also, please add tests.

Test case added

@ibrarahmad ibrarahmad reopened this Feb 2, 2026
Ibrar Ahmed added 2 commits February 2, 2026 19:39
…mode

After insert-only repair with source-of-truth n1:
- All rows from n1 are copied to n2 (upserted)
- n2's unique rows are preserved (not deleted)
- Result: n1 has 0 unique rows, n2 has 2 unique rows

Updated test assertions from incorrect expectations (2, 4, 4) to
correct values (0, 2, 2) that match actual insert-only behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants