-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.sig/transactionSIG: TransactionSIG: Transactiontype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Background
TiDB supports foreign key constraint check by default. When writing a child table, it checks whether the corresponding foreign key value exists in the parent table, and locks the row in the parent table to avoid the foreign key value being deleted by other operations violating the foreign key constraint. However, the current implementation uses exclusive locks for foreign key checks, which can lead to performance bottlenecks in high-concurrency scenarios. To address this, we have introduced shared locks for foreign key checks in pessimistic transactions. This allows multiple transactions to read-lock the same foreign key simultaneously, improving concurrency and performance.
Tracking list(master)
- kvproto add shared lock type
- tikv support shared locks in mvcc storage format
- tikv update lock waiting logic for shared locks
- tikv support shared locks in write commands
- tikv prevent xlock starving
- tikv support deadlock detection
- tikv add shared lock unit tests
- client go support shared locks
- tidb use shared locks in foreign key checks
- tidb coprocessor resolve shared locks
- tidb add integration tests for shared locks
- tidb support shared lock in unistore
- compatibility with other features(1pc, async commit, fair locking features)
Development Task
kvproto
- Add shared lock type.
- 8.5-shared-lock
- master
- release-8.5
tikv
- Update storage format to support shared locks, including
LockandWriterecords, and also enable the MVCC layer to support reading and writing shared locks. - Modify the lock-waiting logic for shared locks.
- Modify the handling logic of write commands to support shared locks, including
acquire_pessimistic_lock,prewrite,commit,resolve_lock, etc.- 8.5-shared-lock
- master
- release-8.5
- Deadlock & Starving
- Scan lock for shared locks.
tidb & client-go
- 8.5-shared-lock
- Update the
LockKeysinterface to support shared locks. - Modify the foreign key check logic to use shared locks.
- Coprocessor resolve shared locks
- Disable some features not compatible yet
- tidb side integration tests
- Update the
- master
- release-8.5
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.sig/transactionSIG: TransactionSIG: Transactiontype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.