-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#24357] docdb: support advisory lock operation
Summary: This diff introduces YBPgsqlLockOp (inherited from YBOperation). The caller can flush such op to DocDB with YBClient. Each YBPgsqlLockOp refers to one lock, each lock should specify: 1. Lock mode: PG_LOCK_SHARE, PG_LOCK_EXCLUSIVE 2. Lock id: dbid, classid, objid, objsubid 3. Acquire with blocking or non-blocking method. Such op is sent to pg_advisory_locks tablet leader with WriteRpc. Conflict Resolution is applied. When all conflicts are resolved, the lock ops will be replicated with RAFT as WriteOperation. When the WriteOperation is RAFT majority-replicated, the intent record corresponding to advisory lock will be written to intentsdb. The format of the intent is `([dboid],[classid,objid,objsubid]),[IntentTypes],HybridTime => TxnId,kRowLock`. See `TransactionalWriter::Apply`. e.g. 1. Intent of a shared lock: ``` SubDocKey(DocKey(0xbde6, [10000], [0, 0, 1]), []) [kStrongRead] HT{ days: 20062 time: 04:53:29.037186 } => TransactionId(649c099f-a889-42dc-a99e-d6f258aeed5b) WriteId(0) l ``` 2. Intent of an exclusive lock: ``` SubDocKey(DocKey(0xbde6, [10000], [0, 0, 1]), []) [kStrongRead, kStrongWrite] HT{ days: 20062 time: 04:53:29.037186 } => TransactionId(649c099f-a889-42dc-a99e-d6f258aeed5b) WriteId(0) l ``` When a transaction is committed/aborted, all locks held by it will be automatically released. This is relying on the existing transaction processing path. **Upgrade/Rollback safety:** The feature is guarded by a TServer gflag yb_enable_advisory_lock (false by default). Jira: DB-13269 Test Plan: advisory_lock-test advisory_lock_doc_operation-test.cc Reviewers: bkolagani, hsunder Reviewed By: bkolagani, hsunder Subscribers: patnaik.balivada, rthallam, ybase, yql, qhu Differential Revision: https://phorge.dev.yugabyte.com/D40471
- Loading branch information
Showing
34 changed files
with
828 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.