storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock#19374
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
b6953d6 to
a76b33f
Compare
| } | ||
| if current_ts <= last_checked_commit_ts { | ||
| // We reach the last handled key | ||
| return self.handle_last_version(last_version, user_key, loaded_commit_ts); |
There was a problem hiding this comment.
What if it hits this branch, the loaded_commit_ts is not updated
There was a problem hiding this comment.
Good question. In this branch we return last_version (captured during the initial prev() loop), not the write at current_ts. loaded_commit_ts is updated together with last_version (only for PUT/DELETE), so it already matches what we return here. Not updating it for LOCK/ROLLBACK is intentional to avoid the original bug where commit_ts could be taken from a newer LOCK. Added test_load_commit_ts_with_top_lock_versions to cover the case (many committed LOCKs on top of a visible PUT) and it asserts the returned commit_ts comes from the PUT.
|
/retest |
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, Connor1996 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
055c58f
into
tikv:release-8.5-20260121-v8.5.5
…_Lock (tikv#19374) close tikv#19312 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (#19374) (#19394) close #19393 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (tikv#19374) close tikv#19312 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (tikv#19374) close tikv#19312 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (#19374) (#19394) (#19397) close #19393 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com> Co-authored-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (tikv#19374) (tikv#19394) close tikv#19393 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…_Lock (tikv#19374) (tikv#19394) close tikv#19393 storage: fix wrong commit_ts in Get/TableScan when latest write is Op_Lock Problem Summary: - When `load_commit_ts=true` and a key has newer committed `Op_Lock` versions on top of the visible `Op_Put`, TiKV may return the lock commit_ts instead of the put commit_ts. What changed: - Fix `PointGetter` to return the commit_ts of the actual write version loaded by `last_change` shortcut, instead of the current cursor version. - Fix backward scanner to only update `loaded_commit_ts` when selecting a `Put` version, avoiding ts overwrite from `Lock/Rollback` versions. Tests: - Add `test_point_get_load_commit_ts_with_top_lock_versions` in `point_getter.rs`. - Add `test_load_commit_ts_with_top_lock_versions` in `scanner/backward.rs`. - Verify existing related tests: - `test_point_get_load_commit_ts` - `test_scan_with_load_commit_ts` Signed-off-by: Chao Wang <cclcwangchao@hotmail.com> Signed-off-by: rishabh mittal <mittalrishabh@gmail.com>
What is changed and how it works?
Issue Number: Close #19312, Close #19393
What's Changed:
Related changes
pingcap/docs/pingcap/docs-cn:Check List
Tests
Side effects
Release note