What happens to in-flight transactions that straddle a YugabyteDB backup boundary after restore?
0 reputation · 20 Aug 2022, 18:33 UTC
0 reputation · 20 Aug 2022, 18:33 UTC
I am designing a backup and recovery runbook for a YugabyteDB universe (assume 2.18 or later) and need to reason precisely about transactional consistency at the snapshot boundary.
My understanding is that a backup captures a consistent distributed snapshot using the hybrid logical clock (HLC) at backup start time, and that restore replays that snapshot into a target universe while yb-admin verify_backup compares tablet checksums against the backup metadata. What I cannot pin down from the documentation is the fate of transactions that were in flight when the HLC cut was taken: committed before the cut on some tablets but still preparing or uncommitted on others.
Specifically, I need to know whether such cross-tablet transactions are deterministically rolled back on restore, partially applied, or resolved through some other rule, and whether checksum verification would even surface a partial-apply anomaly.
Questions:
yb-admin verify_backup validate transactional completeness, or only byte-level tablet integrity?In YugabyteDB (version 2.18 and later), a restored universe guarantees full atomicity for distributed transactions. If a transaction was in-flight when the Hybrid Logical Clock (HLC) snapshot was taken, it is treated as if it never occurred. No subset of a distributed transaction's writes will survive a restore; either the entire transaction committed before the snapshot HLC and is fully present, or it is entirely absent.
YugabyteDB utilizes a consistent distributed snapshot mechanism. The backup process identifies a specific HLC timestamp as the cutoff point. The resolution of transactions straddling this boundary follows these rules:
Because the restore process replays the state of the tablets exactly as they existed at the snapshot HLC, the "partial apply" anomaly is avoided by design. The restored state represents a consistent point-in-time view of the database.
It is important to distinguish between data integrity and transactional completeness when using administrative tools:
| Tool/Method | Scope of Validation | Detects Partial Transactions? |
|---|---|---|
yb-admin verify_backup |
Byte-level tablet checksums vs. backup metadata. | No |
| Tablet/Transaction Logs | Commit/Abort entries relative to the snapshot HLC. | Yes |
yb-admin verify_backup validates that the restored tablet data matches the backup source exactly. It does not analyze the logical completeness of transactions; it only ensures that the bytes restored are the bytes that were backed up.
To verify the fate of a specific transaction, you must examine the transaction logs (yb-txn-logs) or tablet logs. Look for the commit entries associated with the transaction ID around the snapshot HLC. If a transaction was in-flight during the backup, you will find no corresponding commit record for that transaction within the snapshot's timestamp range.
Required Diagnostic Detail: To provide a more tailored verification strategy, please specify if you are using Full or Incremental backups, as the chain of HLC snapshots may affect how you trace transaction boundaries across multiple restore points.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.