[YSQL] TableLocks: Create and re-use docdb transactions for read-only transactions #24596
Open
1 task done
Labels
area/ysql
Yugabyte SQL (YSQL)
kind/new-feature
This is a request for a completely new feature
priority/medium
Medium priority issue
Jira Link: DB-13634
Description
In #23045, we introduced a tserver local object lock manager. The intention was to tag locks to
SessionIDHostPair = std::pair<const uint64_t, const std::string>
since not all ysql transaction have a distributed transaction on the docdb side (and hence no txn id tag the lock could be tagged against)But we could end up with deadlocks spanning table/object locks and row-level locks which would go undetected if we have different deadlock detectors running for table locks and row locks. For example, consider the below
Note: As of today, each DDL operates under its own transaction. But there is ongoing work to support DDL+DML transactionality, when we could run into the above deadlock.
But starting a distributed txn for every ysql txn would introduce additional latencies for read-only txn, fast path writes etc.
To address this problem, we could start a distributed docdb transaction early (even for read-only txns), and keep re-using the transaction until a ysql transaction write comes in. The next subsequent statement would start another docdb transaction.
That way, we would have an identifier to tag object/table locks to. For instance, consider the below example
Issue Type
kind/new-feature
Warning: Please confirm that this issue does not contain any sensitive information
The text was updated successfully, but these errors were encountered: