rocksdb/unreleased_history/public_api_changes
Yu Zhang 210c8df820 Use do_validate flag to control timestamp based validation in WriteCommittedTxn::GetForUpdate (#12369)
Summary:
When PR https://github.com/facebook/rocksdb/issues/9629 introduced user-defined timestamp support for `WriteCommittedTxn`, it adds this usage mandate for API `GetForUpdate` when UDT is enabled. The `do_validate` flag has to be true, and user should have already called `Transaction::SetReadTimestampForValidation` to set a read timestamp for validation. The rationale behind this mandate is this:
1) with do_vaildate = true, `GetForUpdate` could verify this relationships: let's denote the user-defined timestamp in db for the key as  `Ts_db` and the read timestamp user set via `Transaction::SetReadTimestampForValidation` as `Ts_read`. UDT based validation will only pass if `Ts_db <= Ts_read`.
5950907a82/utilities/transactions/transaction_util.cc (L141)

2)  Let's denote the committed timestamp set via `Transaction::SetCommitTimestamp` to be `Ts_cmt`. Later `WriteCommitedTxn::Commit` would only pass if this condition is met: `Ts_read < Ts_cmt`. 5950907a82/utilities/transactions/pessimistic_transaction.cc (L431)

Together these two checks can ensure `Ts_db < Ts_cmt` to meet the user-defined timestamp invariant that newer timestamp should have newer sequence number.

The `do_validate` flag was originally intended to make snapshot based validation optional. If it's true, `GetForUpdate` checks no entry is written after the snapshot. If it's false, it will skip this snapshot based validation. In this PR, we are making the UDT based validation configurable too based on this flag instead of mandating it for below reasons: 1) in some cases the users themselves can enforce aformentioned invariant on their side independently, without RocksDB help, for example, if they are managing a monotonically increasing timestamp, and their transactions are only committed in a single thread. So they don't need this UDT based validation and wants to skip it, 2) It also could be expensive or not practical for users to come up with such a read timestamp that is exactly in between their commit timestamp and the db's timestamp. For example, in aformentioned case where a monotonically increasing timestamp is managed, the users would need to access this timestamp both for setting the read timestamp and for setting the commit timestamp. So it's preferable to skip this check too.

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

Test Plan: added unit tests

Reviewed By: ltamasi

Differential Revision: D54268920

Pulled By: jowlyzhang

fbshipit-source-id: ca7693796f9bb11f376a2059d91841e51c89435a
2024-03-07 14:58:10 -08:00
..
.gitkeep Better management of unreleased HISTORY (#11481) 2023-05-30 16:42:49 -07:00
best_effort_atomic.md Best-effort recovery support for atomic flush (#12406) 2024-03-06 14:40:40 -08:00
bottommost_temperature.md Remove bottommost_temperature (#12389) 2024-02-27 14:48:00 -08:00
new_remote_compaction_api.md Update APIs to support generic unique identifier format (#12384) 2024-03-01 09:55:30 -08:00
optional_skip_udt_based_validation_write_committed.md Use do_validate flag to control timestamp based validation in WriteCommittedTxn::GetForUpdate (#12369) 2024-03-07 14:58:10 -08:00
perf_level_for_blocking_events.md Add a perf level for measuring user thread block time (#12368) 2024-02-22 12:14:53 -08:00
rate_limiter_burst.md Decouple RateLimiter burst size and refill period (#12379) 2024-02-26 16:55:13 -08:00
write-memtable-time-new-perf-level.md Add write_memtable_time to perf level kEnableWait (#12394) 2024-02-29 15:08:26 -08:00