rocksdb/utilities/transactions/lock/range/range_tree/lib
Herman Lee d9d456de49 Fix locktree accesses to PessimisticTransactions (#9898)
Summary:
The current locktree implementation stores the address of the
PessimisticTransactions object as the TXNID. However, when a transaction
is blocked on a lock, it records the list of waitees with conflicting
locks using the rocksdb assigned TransactionID. This is performed by
calling GetID() on PessimisticTransactions objects of the waitees,
and then recorded in the waiter's list.

However, there is no guarantee the objects are valid when recording the
waitee list during the conflict callbacks because the waitee
could have released the lock and freed the PessimisticTransactions
object.

The waitee/txnid values are only valid PessimisticTransaction objects
while the mutex for the root of the locktree is held.

The simplest fix for this problem is to use the address of the
PessimisticTransaction as the TransactionID so that it is consistent
with its usage in the locktree. The TXNID is only converted back to a
PessimisticTransaction for the report_wait callbacks. Since
these callbacks are now all made within the critical section where the
lock_request queue mutx is held, these conversions will be safe.
Otherwise, only the uint64_t TXNID of the waitee is registerd
with the waiter transaction. The PessimisitcTransaction object of the
waitee is never referenced.

The main downside of this approach is the TransactionID will not change
if the PessimisticTransaction object is reused for new transactions.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9898

Test Plan:
Add a new test case and run unit tests.
Also verified with MyRocks workloads using range locks that the
crash no longer happens.

Reviewed By: riversand963

Differential Revision: D35950376

Pulled By: hermanlee

fbshipit-source-id: 8c9cae272e23e487fc139b6a8ed5b8f8f24b1570
2022-04-27 09:12:52 -07:00
..
ft Apply the changes from: PS-5501 : Re-license PerconaFT 'locktree' to Apache V2 (#7801) 2020-12-22 14:47:41 -08:00
locktree Fix locktree accesses to PessimisticTransactions (#9898) 2022-04-27 09:12:52 -07:00
portability Add support for building on s390x platform (#8962) 2021-10-22 10:13:15 -07:00
util Apply the changes from: PS-5501 : Re-license PerconaFT 'locktree' to Apache V2 (#7801) 2020-12-22 14:47:41 -08:00
COPYING.AGPLv3 LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00
COPYING.APACHEv2 LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00
COPYING.GPLv2 LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00
db.h LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00
README LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00
standalone_port.cc LockTree library, originally from PerconaFT (#7753) 2020-12-09 12:10:57 -08:00

The files in this directory originally come from
https://github.com/percona/PerconaFT/.

This directory only includes the "locktree" part of PerconaFT, and its
dependencies.

The following modifications were made:
- Make locktree usable outside of PerconaFT library
- Add shared read-only lock support

The files named *_subst.* are substitutes of the PerconaFT's files, they
contain replacements of PerconaFT's functionality.