[2DC] Apply transactions atomically on replica universe #1808
Labels
area/docdb
YugabyteDB core features
roadmap-tracking-issue
This issue tracks a major roadmap item, and usually appears in the roadmap list.
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 toWAITING_TO_COMMIT
.If transaction status is
WAITING_TO_COMMIT
and all involved tablets have received theirApplying
message, then transaction leader changes transaction status toCOMMITTED
and sends a newApplying
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 atWAITING_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 theirApplying
records. If not, then it will set transaction status toWAITING_TO_COMMIT
. If all involved tablets have receivedApplying
record, then the transaction leader sets the status toCOMMITTED
, and sends a newApplying
record to all involved tablets, notifying them to commit the transaction.The text was updated successfully, but these errors were encountered: