Skip to content

Commit

Permalink
Update docs/design/2024-01-22-ticdc-large-txn-not-block-wm.md
Browse files Browse the repository at this point in the history
Co-authored-by: CharlesCheung <[email protected]>
  • Loading branch information
zhangjinpeng87 and CharlesCheung96 authored Jan 23, 2024
1 parent b46c57b commit 9b20925
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/design/2024-01-22-ticdc-large-txn-not-block-wm.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Because the total write data is massive in the prewrite stage for a large transa
## Mechanism of updating primary key TTL periodically for large transaction

In TiDB's 2PC transaction protocol, TiDB prewrites all kv pairs concurrently at the prewrite stage, and then commit the primary key first and then asynchrously commit all secondary keys. If a read request encountered a prewritten but uncommitted data, it will try to check its primary key's status(committed or rollbacked, or still ongoing) to determine wait the data to be committed or rollback it. The read request uses the TTL information enveloped in the primary key to determine if this is an aborted transaction caused by crashed TiDB instances or if this is an ongoing transaction if the TTL is still alive.
For a normal transaction, the default TTL is 3s ahead of the transaction's start-ts. It means if a read request encounters a lock whose primary key's status is undertimed, the read request will check the TTL of this primary key. If the TTL is less than the read request's current ts, the read request can rollback this undertermined lock to make this read request unblocked.
For a normal transaction, the default TTL is 3s ahead of the transaction's start-ts. It means if a read request encounters a lock whose primary key's status is undetermined, the read request will check the TTL of this primary key. If the TTL is less than the read request's current ts, the read request can rollback this undetermined lock to make this read request unblocked.
In order to prevent the read request and other lock resolving mechanisms disturbing or aborting a long running large transaction, the large transaction will periodically update and advance the TTL of its primary key. The following diagram demostrate how large transaction update TTL of its primary key:

![image](../media/large-txn-no-block-wm-2.png)
Expand Down

0 comments on commit 9b20925

Please sign in to comment.