Skip to content

[2DC] Apply transactions atomically on replica universe #1808

@ndeodhar

Description

@ndeodhar

To apply transactions atomically on replica universe, we need to introduce an additional status WAITING_TO_COMMIT. This will wait for all replica tablets to receive CDC changes for a transaction. Once all tablets have received changes and recorded those in their WALs, the transaction can be committed.

Flow will be:

  • Replica tserver receives the replicated WAL record(s) in response to GetCDCRecords RPC.

  • If the record is Transaction create/update: It sends the transaction record to transaction tablet leader which adds to its WAL.

  • If record is Write op for a transaction: It sends the record to tablet leader of the key. The tablet leader ensures that there is no conflict, writes the record to its WAL, and creates provisional record.

  • If record is Transaction Applying record for a tablet involved in the transaction: Replication leader will send an RPC to the transaction leader, indicating that the tablet involved has received all records for the transaction. Transaction leader will record this information in its WAL and transactions table (using field tablets_received_applying_record) and sets transaction status to WAITING_TO_COMMIT.

  • If transaction status is WAITING_TO_COMMIT and all involved tablets have received their Applying message, then transaction leader changes transaction status to COMMITTED and sends a new Applying message to all involved tablets, notifying them to commit the transaction. If all tablets have not yet received all records involved in the transaction, then the status remains unchanged at WAITING_TO_COMMIT and the changes are not yet applied on the replica universe.

  • Similar to above, if record is Transaction Commit record: Replication leader will send an RPC to transaction leader. Transaction leader checks whether all tablets involved in the transaction have received their Applying records. If not, then it will set transaction status to WAITING_TO_COMMIT. If all involved tablets have received Applying record, then the transaction leader sets the status to COMMITTED, and sends a new Applying record to all involved tablets, notifying them to commit the transaction.

Metadata

Metadata

Assignees

Labels

area/docdbYugabyteDB core featuresroadmap-tracking-issueThis issue tracks a major roadmap item, and usually appears in the roadmap list.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions