Skip to content

Fix missing SingleDeleteCF in PessimisticTransaction::LockBatch (#15511) - #15531

Open
midverm wants to merge 1 commit into
meta:mainfrom
midverm:fix-15511-single-delete-lock-batch
Open

midverm wants to merge 1 commit into
meta:mainfrom
midverm:fix-15511-single-delete-lock-batch

Conversation

@midverm

@midverm midverm commented Oct 31, 2026

Copy link
Copy Markdown

Summary

Fixes #15511.

In PessimisticTransaction::LockBatch(), RocksDB locks keys in a batch before writing them with TransactionDB::Write().

SingleDeleteCF was missing from this handler, which caused two bugs:

  1. On the default column family: The key was never locked. A SingleDelete could delete a key while another transaction had it locked, without waiting for the lock.
  2. On non-default column families: The write failed with an InvalidArgument error.

This PR adds SingleDeleteCF to LockBatch so single deletes are locked just like normal deletes.

Test Plan

  • Added SingleDeleteBatchLocking in utilities/transactions/transaction_test.cc.
  • Verified that:
    • Batched single deletes wait and time out when a key is locked by another transaction.
    • Batched single deletes on non-default column families now succeed.

…#15511)

Summary:
In PessimisticTransaction::LockBatch(), the internal WriteBatch::Handler
overrides PutCF, PutEntityCF, MergeCF, and DeleteCF to record and lock
all keys before committing writes through TransactionDB::Write().
However, SingleDeleteCF was missing.

As a result:
1. On the default column family, WriteBatch::Handler::SingleDeleteCF
   fell back to SingleDelete(key) (a no-op in Handler) and returned OK,
   so keys were not recorded or locked. A concurrent SingleDelete in
   TransactionDB::Write() could delete a key locked exclusively by an
   active transaction without waiting or timing out.
2. On any non-default column family, the base SingleDeleteCF returned
   InvalidArgument ("non-default column family and SingleDeleteCF not implemented"),
   causing valid batched SingleDelete writes on non-default column families
   to fail.

This fix overrides SingleDeleteCF in LockBatch::Handler to record the key,
matching the behavior of DeleteCF.

Test Plan:
- Added SingleDeleteBatchLocking unit test in utilities/transactions/transaction_test.cc.
- Verified with standalone reproducer from meta#15511:
  - Batched SingleDelete on default CF times out when key is exclusively locked.
  - Batched SingleDelete on non-default CF succeeds and deletes the key.
@meta-cla meta-cla Bot added the CLA Signed label Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keys locked by a pessimistic transaction can be deleted by a batched SingleDelete

1 participant