Add range_versions field to Request used by tici#1356
Add range_versions field to Request used by tici#1356ti-chi-bot[bot] merged 8 commits intopingcap:masterfrom
Conversation
proto/coprocessor.proto
Outdated
| string connection_alias = 13; // This is the session alias between a client and tidb | ||
|
|
||
| repeated TableShardInfos table_shard_infos= 14; // Shard infos for FTS index, used by TiFlash reading TiCI. | ||
| // versions of each reange, used in TiCI lookup, if range_versions is set, then len(range_versions) should equal to len(ranges), and all the range in ranges should be point range |
There was a problem hiding this comment.
| // versions of each reange, used in TiCI lookup, if range_versions is set, then len(range_versions) should equal to len(ranges), and all the range in ranges should be point range | |
| // versions of each range, used in TiCI lookup, if range_versions is set, then len(range_versions) should equal to len(ranges), and all the range in ranges should be point range |
113cbfc to
5d3f2c4
Compare
proto/coprocessor.proto
Outdated
|
|
||
| repeated TableShardInfos table_shard_infos= 14; // Shard infos for FTS index, used by TiFlash reading TiCI. | ||
| // versions of each range, used in TiCI lookup, if range_versions is set, then len(range_versions) should equal to len(ranges), and all the range in ranges should be point range | ||
| repeated uint64 range_versions = 15; |
There was a problem hiding this comment.
The range_versions is a parallel array to ranges, which is easy to desync when ranges are reordered/filtered/deduped; a safer modeling is
“version attached to range” (e.g. extend KeyRange, or introduce VersionedKeyRange { KeyRange range = 1; fixed64 read_ts = 2; }) to prevent subtle mismatches.
proto/coprocessor.proto
Outdated
| string connection_alias = 13; // This is the session alias between a client and tidb | ||
|
|
||
| repeated TableShardInfos table_shard_infos= 14; // Shard infos for FTS index, used by TiFlash reading TiCI. | ||
| // versions of each range, used in TiCI lookup, if range_versions is set, then len(range_versions) should equal to len(ranges), and all the range in ranges should be point range |
There was a problem hiding this comment.
For repeated in proto3 a clearer invariant is “when range_versions is non-empty” instead of range_versions is set.
| } | ||
|
|
||
| service VersionedKv { | ||
| rpc VersionedCoprocessor(coprocessor.Request) returns (coprocessor.Response) {} |
There was a problem hiding this comment.
Better comment about the invariants and usage scenarios here to avoid mis-usages for the new interface.
| repeated TableShardInfos table_shard_infos= 14; // Shard infos for FTS index, used by TiFlash reading TiCI. | ||
| // Versioned point ranges for TiCI lookup. | ||
| // When `versioned_ranges` is non-empty, all `versioned_ranges[i].range` must be point range. | ||
| repeated VersionedKeyRange versioned_ranges = 15; |
There was a problem hiding this comment.
Is this still needed if versioned_ranges is included in repeated StoreBatchTask tasks = 11;?
There was a problem hiding this comment.
When tidb variable StoreBatchSize = 0, StoreBatchTask will not be used. In this case, this field will be used.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, windtalker 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:
|
…19302) close #19357 coprocessor: support versioned lookup via per-key read ts (range_versions) This introduces a special "versioned lookup" read path for coprocessor DAG requests: - When `coppb::Request.range_versions` is empty, behavior is unchanged. - When `range_versions` is provided: - `ranges.len()` must equal `range_versions.len()` - all `ranges` must be point ranges - only DAG + TableScan is allowed - each `ranges[i]` is read at `range_versions[i]` (per-key read ts), while bypassing txn-related checks: - endpoint memory lock checking / max_ts update - lock-cf checking in PointGetter - RcCheckTs newer-ts conflicts Implementation overview: - Plumb `range_versions` through Endpoint -> DagHandlerBuilder -> TableScan -> RangesScanner. - Add Store/SnapshotStore `get_entry_at_ts` backed by PointGetter with `bypass_txn_check`. - Disable coprocessor cache for versioned lookup to avoid unintended cache hits. Tests: - Add unit tests for validation/guard rails and bypass behaviors. - Add executor tests to verify per-range ts usage (including backward scan alignment). - Extend coprocessor integration tests for reading older versions. Dependencies: - Requires kvproto change adding `coppb::Request.range_versions` (kvproto PR: pingcap/kvproto#1356). The temporary `[patch]` in `Cargo.toml` can be removed after kvproto is merged. Signed-off-by: wshwsh12 <793703860@qq.com>
No description provided.