Skip to content

staleread: Allow passing TSO in AS OF TIMESTAMP clause#66643

Open
madhavramesh wants to merge 6 commits intopingcap:masterfrom
madhavramesh:use-tso-as-of-timestamp
Open

staleread: Allow passing TSO in AS OF TIMESTAMP clause#66643
madhavramesh wants to merge 6 commits intopingcap:masterfrom
madhavramesh:use-tso-as-of-timestamp

Conversation

@madhavramesh
Copy link

@madhavramesh madhavramesh commented Mar 3, 2026

What problem does this PR solve?

Issue Number: close #64314

Problem Summary: The change allows specifying TSO when using AS OF TIMESTAMP syntax. Currently, AS OF TIMESTAMP only supports datetime, which is asymmetric with tidb_snapshot system variable that accepts both datetime or TSO.

Using tidb_snapshot is inconvenient since it pollute the session if not reverted. Using AS OF TIMESTAMP is much more convenient but lacks precision, which this PRs address.

What changed and how does it work?

If parsing the timestamp as datetime fails, and the expression is a valid integer, parse it as TSO. This approach keeps backwards compatibility as discussed in #64314.

One caveat is that if someone specifies a string in the format 'YYYYMMDDHHMMSS', AS OF TIMESTAMP will treat it as a datetime, while @tidb_snapshot treats as a int. This is an explicit choice to keep backwards compatability.

Check List

Tests

Side effects

  • No Performance regression: No, only processed if parsing the timestamp as date time fails. Even then should be minimal.
  • Does not break backward compatibility. All valid DateTime expressions are parsed as DateTime.

Release note

Allow specifying a TSO in addition to DateTime in AS OF TIMESTAMP sql expressions.

Summary by CodeRabbit

  • New Features
    • AS OF TIMESTAMP accepts numeric TSO values as well as datetime strings; compact datetime forms are interpreted as datetimes with subsecond truncation and preserved precision where applicable.
  • Tests
    • Added unit and integration tests covering numeric TSO, compact-datetime parsing, transactional as-of reads, and handling of various invalid AS OF expressions.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 3, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@pantheon-ai
Copy link

pantheon-ai bot commented Mar 3, 2026

Review Complete

Findings: 1 issues
Posted: 1
Duplicates/Skipped: 0

@ti-chi-bot ti-chi-bot bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. contribution This PR is from a community contributor. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 3, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 3, 2026

Hi @madhavramesh. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@tiprow
Copy link

tiprow bot commented Mar 3, 2026

Hi @madhavramesh. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@madhavramesh madhavramesh changed the title Allow passing TSO in AS OF TIMESTAMP staleread: Allow passing TSO in AS OF TIMESTAMP Mar 3, 2026
@madhavramesh madhavramesh changed the title staleread: Allow passing TSO in AS OF TIMESTAMP staleread: Allow passing TSO in AS OF TIMESTAMP clause Mar 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: abb118d1-2364-40ba-a261-e9cf5b449146

📥 Commits

Reviewing files that changed from the base of the PR and between d1a6ede and 6c20eee.

📒 Files selected for processing (2)
  • pkg/sessiontxn/staleread/BUILD.bazel
  • pkg/sessiontxn/staleread/util.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/sessiontxn/staleread/BUILD.bazel
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/sessiontxn/staleread/util.go

📝 Walkthrough

Walkthrough

AS OF TIMESTAMP parsing now tries to interpret the expression as a datetime first; if that fails it falls back to parsing a numeric TSO (uint64), validates the TSO's physical time, and returns an exact staleness TS. New unit and integration tests exercise datetime, compact-datetime, numeric TSO, and invalid cases.

Changes

Cohort / File(s) Summary
Core Stale Read Logic
pkg/sessiontxn/staleread/util.go
CalculateAsOfTsExpr now attempts datetime parsing (parseTsExprAsDatetime) then falls back to numeric TSO extraction (tsoFromDatum), validates positive TSO and physical ms > 1356998400000, and calls snapshot-read safety check before returning.
Unit Tests
pkg/sessiontxn/staleread/processor_test.go
Adds three tests: TestStaleReadSupportDateTimeAndTSO, TestStaleReadCompactDateTime, and TestStaleReadInvalidExpression to cover datetime vs numeric TSO parsing, compact-datetime interpretation and precision trimming, and error cases. Tests reuse existing helpers and a mocked embed-unistore store.
Integration Tests
tests/integrationtest/t/executor/stale_txn.test, tests/integrationtest/r/executor/stale_txn.result
Adds scenarios that create t1, capture last_commit_ts and prev_commit_ts, and exercise AS OF TIMESTAMP with both integer TSO and commit-timestamp values, including invalid-date checks and transactional snapshot reads and counts.
Test Build Config
pkg/sessiontxn/staleread/BUILD.bazel
Adjusts go_test target staleread_test shard_count from 9 to 12.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 I hopped through timestamps, small and grand,

From datetimes snug to TSO land.
I kept the ticks, I kept the tune,
Found old rows by the light of moon.
🥕 Gentle hops — exact history in hand.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: enabling TSO support in the AS OF TIMESTAMP clause, which is the primary objective of the pull request.
Description check ✅ Passed The PR description comprehensively addresses all required sections: problem statement (issue #64314), implementation approach with design decisions, testing coverage (unit, integration, manual), side effects analysis, and a release note.
Linked Issues check ✅ Passed The implementation aligns with issue #64314 objectives: it enables TSO specification in AS OF TIMESTAMP, supports both datetime and TSO (like tidb_snapshot), preserves backward compatibility, and avoids session state pollution.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue: test coverage for TSO parsing in AS OF TIMESTAMP, utility function updates for parsing logic, and integration/unit tests. The BUILD.bazel shard count increase is a reasonable adjustment for added test volume.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.3)

Command failed


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/sessiontxn/staleread/util.go (1)

69-77: Consider handling integer Datum kinds for TSO values.

The current implementation only parses TSO from KindString and KindBytes. If a user passes an integer variable (e.g., SELECT ... AS OF TIMESTAMP @int_var`` where @int_var is set as an integer), it would fail since integer Datum kinds (`KindInt64`, `KindUint64`) aren't handled in the TSO fallback path.

This may be acceptable if the primary use case is string literals from SQL, but worth considering for completeness.

Optional enhancement to handle integer kinds
 	// If datetime conversion failed, try to parse as a TiDB TSO (not a Unix timestamp).
 	// A TiDB TSO encodes a physical timestamp (ms since epoch) in the high bits and a logical
 	// counter in the low 18 bits. We validate that the physical component represents a
 	// reasonable time (after 2013-01-01).
+	var tso uint64
+	var parseErr error
 	if tsVal.Kind() == types.KindString || tsVal.Kind() == types.KindBytes {
-		if tso, err := strconv.ParseUint(tsVal.GetString(), 10, 64); err == nil {
-			physicalMS := oracle.ExtractPhysical(tso)
-			// 1356998400000 ms = 2013-01-01T00:00:00Z, a reasonable lower bound for any TiDB TSO.
-			if physicalMS > 1356998400000 {
-				return tso, nil
-			}
-		}
+		tso, parseErr = strconv.ParseUint(tsVal.GetString(), 10, 64)
+	} else if tsVal.Kind() == types.KindInt64 || tsVal.Kind() == types.KindUint64 {
+		tso, parseErr = tsVal.GetUint64(), nil
+	}
+	if parseErr == nil && tso > 0 {
+		physicalMS := oracle.ExtractPhysical(tso)
+		// 1356998400000 ms = 2013-01-01T00:00:00Z, a reasonable lower bound for any TiDB TSO.
+		if physicalMS > 1356998400000 {
+			return tso, nil
+		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/sessiontxn/staleread/util.go` around lines 69 - 77, The tsVal TSO parsing
only handles types.KindString and types.KindBytes, so add handling for integer
Datum kinds (types.KindInt64 and types.KindUint64) in the same fallback block:
if tsVal.Kind() == types.KindInt64 or types.KindUint64, read the numeric TSO via
tsVal.GetInt64()/tsVal.GetUint64() (casting to uint64 as needed), call
oracle.ExtractPhysical on that value, validate against the same lower bound
(1356998400000), and return the tso if valid; keep the existing string/bytes
parsing path unchanged and ensure the same error/return behavior if validation
fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/sessiontxn/staleread/util.go`:
- Around line 69-77: The tsVal TSO parsing only handles types.KindString and
types.KindBytes, so add handling for integer Datum kinds (types.KindInt64 and
types.KindUint64) in the same fallback block: if tsVal.Kind() == types.KindInt64
or types.KindUint64, read the numeric TSO via tsVal.GetInt64()/tsVal.GetUint64()
(casting to uint64 as needed), call oracle.ExtractPhysical on that value,
validate against the same lower bound (1356998400000), and return the tso if
valid; keep the existing string/bytes parsing path unchanged and ensure the same
error/return behavior if validation fails.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a171feb and 87dbe91.

📒 Files selected for processing (4)
  • pkg/sessiontxn/staleread/processor_test.go
  • pkg/sessiontxn/staleread/util.go
  • tests/integrationtest/r/executor/stale_txn.result
  • tests/integrationtest/t/executor/stale_txn.test

// A TiDB TSO encodes a physical timestamp (ms since epoch) in the high bits and a logical
// counter in the low 18 bits. We validate that the physical component represents a
// reasonable time (after 2013-01-01).
if tsVal.Kind() == types.KindString || tsVal.Kind() == types.KindBytes {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] TSO parsing ignores non-string integer-like values

Why: The TSO fallback only triggers when the evaluated datum kind is KindString or KindBytes. If a user passes an integer-valued expression — e.g. AS OF TIMESTAMP CAST(@tso AS UNSIGNED), arithmetic on a TSO, or JSON_EXTRACT(...) returning a number — the datetime parse fails and the error is returned directly without attempting TSO parsing. This makes the feature incomplete and surprising, since the PR's stated goal is to accept raw TSO integers.

Evidence: pkg/sessiontxn/staleread/util.go:69

if tsVal.Kind() == types.KindString || tsVal.Kind() == types.KindBytes {
    if tso, err := strconv.ParseUint(tsVal.GetString(), 10, 64); ...
}

Non-string kinds (KindInt64, KindUint64, KindMysqlJSON) fall through to return 0, datetimeErr without TSO fallback. Note: this also affects AS OF TIMESTAMP TIDB_CURRENT_TSO() (int-returning builtin) unless explicitly cast to string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL this.

Copy link

@pantheon-ai pantheon-ai bot Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The master agent encountered an error while processing. Please try again later.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 4, 2026
Copy link
Member

@nolouch nolouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nolouch
Copy link
Member

nolouch commented Mar 9, 2026

ptal @cfzjywxk @JmPotato

// A TiDB TSO encodes a physical timestamp (ms since epoch) in the high bits and a logical
// counter in the low 18 bits. We validate that the physical component represents a
// reasonable time (after 2013-01-01).
if tsVal.Kind() == types.KindString || tsVal.Kind() == types.KindBytes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL this.

physicalMS := oracle.ExtractPhysical(tso)
// 1356998400000 ms = 2013-01-01T00:00:00Z, a reasonable lower bound for any TiDB TSO.
if physicalMS > 1356998400000 {
return tso, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to validate the upper bounds to avoid future ts, like
ValidateSnapshotReadTS, future ts may break linearizability when async commit is enabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to check this also

@cfzjywxk cfzjywxk requested review from MyonKeminta and ekexium March 12, 2026 12:48
@cfzjywxk
Copy link
Contributor

@MyonKeminta @ekexium
PTAL

}
}

return 0, datetimeErr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user passes in an invalid TSO, the error returned is still datetimeErr. This is acceptable but slightly confusing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this to return a more specific error

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/sessiontxn/staleread/util.go (1)

72-76: Consider extracting the magic number as a named constant.

The value 1356998400000 (2013-01-01T00:00:00Z in milliseconds) is used as a lower bound for valid TSOs but isn't self-documenting. A named constant would improve clarity and make it easier to maintain if this threshold ever needs adjustment.

Suggested improvement
+// minValidTSOPhysicalMS is the minimum physical timestamp (in milliseconds) for a valid TiDB TSO.
+// This corresponds to 2013-01-01T00:00:00Z, a reasonable lower bound predating TiDB's existence.
+const minValidTSOPhysicalMS = 1356998400000
+
 func CalculateAsOfTsExpr(ctx context.Context, sctx planctx.PlanContext, tsExpr ast.ExprNode) (uint64, error) {
     ...
     physicalMS := oracle.ExtractPhysical(tso)
-    // 1356998400000 ms = 2013-01-01T00:00:00Z, a reasonable lower bound for any TiDB TSO
-    if physicalMS <= 1356998400000 {
+    if physicalMS <= minValidTSOPhysicalMS {
         return 0, plannererrors.ErrAsOf.FastGenWithCause("invalid TSO timestamp: TSO is before 2013-01-01")
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/sessiontxn/staleread/util.go` around lines 72 - 76, Extract the hardcoded
1356998400000 literal into a named constant (e.g., minValidTSOPhysicalMS or
MinTSOTimeMs) and replace its use in the TSO lower-bound check; update the check
that uses physicalMS (and add a short comment explaining that the constant
represents 2013-01-01T00:00:00Z in ms) so the intent is clear and the threshold
can be adjusted centrally in functions like the TSO validation logic where
physicalMS := oracle.ExtractPhysical(tso) is compared.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/sessiontxn/staleread/util.go`:
- Around line 72-76: Extract the hardcoded 1356998400000 literal into a named
constant (e.g., minValidTSOPhysicalMS or MinTSOTimeMs) and replace its use in
the TSO lower-bound check; update the check that uses physicalMS (and add a
short comment explaining that the constant represents 2013-01-01T00:00:00Z in
ms) so the intent is clear and the threshold can be adjusted centrally in
functions like the TSO validation logic where physicalMS :=
oracle.ExtractPhysical(tso) is compared.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bc1f4352-c33f-4e89-866e-9a5890c0d0e6

📥 Commits

Reviewing files that changed from the base of the PR and between 87dbe91 and 5a7bd7a.

📒 Files selected for processing (4)
  • pkg/sessiontxn/staleread/processor_test.go
  • pkg/sessiontxn/staleread/util.go
  • tests/integrationtest/r/executor/stale_txn.result
  • tests/integrationtest/t/executor/stale_txn.test
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integrationtest/r/executor/stale_txn.result

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/sessiontxn/staleread/util.go (1)

80-82: Avoid validating the same read TS twice on the TSO path.

CalculateAsOfTsExpr validates tso here, and the caller in pkg/sessiontxn/staleread/processor.go (Line 280-292) validates again after this function returns. For TSO inputs this adds an extra oracle validation round trip per query. Consider centralizing this check in one layer to avoid duplicate PD/oracle pressure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/sessiontxn/staleread/util.go` around lines 80 - 82, CalculateAsOfTsExpr
currently calls sessionctx.ValidateSnapshotReadTS(ctx, sctx.GetStore(), tso,
true) which causes a duplicate oracle/PD validation because its caller in
pkg/sessiontxn/staleread/processor.go already validates TSO; remove the
ValidateSnapshotReadTS call from CalculateAsOfTsExpr (or change
CalculateAsOfTsExpr to accept a skipValidation boolean and bypass the call) and
ensure the single responsibility for TSO validation remains in the caller
(processor.go) so TSO inputs only trigger one ValidateSnapshotReadTS invocation;
update function signature/use sites if you add the skip flag and keep the
validation call in processor.go (use sessionctx.ValidateSnapshotReadTS there) as
the centralized check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/sessiontxn/staleread/processor_test.go`:
- Around line 238-263: Update TestStaleReadSupportDateTimeAndTSO to include a
regression case that exercises non-string numeric Datum kinds
(KindInt64/KindUint64) by invoking processor.OnSelectTable with an AST that uses
an unquoted numeric expression or CAST(<tso> AS UNSIGNED) for AS OF TIMESTAMP;
use genStaleReadPoint to get a tso value, call createProcessor and OnSelectTable
with astTableWithAsOf using that numeric expression, then assert
processor.GetStalenessReadTS() equals the expected tso to ensure tsoFromDatum
handles non-string numerics.

---

Nitpick comments:
In `@pkg/sessiontxn/staleread/util.go`:
- Around line 80-82: CalculateAsOfTsExpr currently calls
sessionctx.ValidateSnapshotReadTS(ctx, sctx.GetStore(), tso, true) which causes
a duplicate oracle/PD validation because its caller in
pkg/sessiontxn/staleread/processor.go already validates TSO; remove the
ValidateSnapshotReadTS call from CalculateAsOfTsExpr (or change
CalculateAsOfTsExpr to accept a skipValidation boolean and bypass the call) and
ensure the single responsibility for TSO validation remains in the caller
(processor.go) so TSO inputs only trigger one ValidateSnapshotReadTS invocation;
update function signature/use sites if you add the skip flag and keep the
validation call in processor.go (use sessionctx.ValidateSnapshotReadTS there) as
the centralized check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 796e970c-78eb-44a8-a456-a878194da3e0

📥 Commits

Reviewing files that changed from the base of the PR and between 5a7bd7a and d1a6ede.

📒 Files selected for processing (4)
  • pkg/sessiontxn/staleread/processor_test.go
  • pkg/sessiontxn/staleread/util.go
  • tests/integrationtest/r/executor/stale_txn.result
  • tests/integrationtest/t/executor/stale_txn.test
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/integrationtest/t/executor/stale_txn.test
  • tests/integrationtest/r/executor/stale_txn.result

Comment on lines +238 to +263
func TestStaleReadSupportDateTimeAndTSO(t *testing.T) {
store := testkit.CreateMockStore(t, mockstore.WithStoreType(mockstore.EmbedUnistore))
tk := testkit.NewTestKit(t, store)
p1 := genStaleReadPoint(t, tk)
p2 := genStaleReadPoint(t, tk)

require.NotEqual(t, p1.ts, p2.ts)

// Reading AS OF TIMESTAMP 'TSO' should be parsed correctly.
processor := createProcessor(t, tk.Session())
err := processor.OnSelectTable(astTableWithAsOf(t, fmt.Sprintf("%d", p1.ts)))
require.NoError(t, err)
require.Equal(t, processor.GetStalenessReadTS(), p1.ts)

// Reading AS OF TIMESTAMP 'TSO' does not lose precision.
processor = createProcessor(t, tk.Session())
err = processor.OnSelectTable(astTableWithAsOf(t, fmt.Sprintf("%d", p1.ts+1)))
require.NoError(t, err)
require.Equal(t, processor.GetStalenessReadTS(), p1.ts+1)

// Reading AS OF TIMESTAMP 'YYYY-MM-DD HH:MM:SS' should be parsed correctly.
processor = createProcessor(t, tk.Session())
err = processor.OnSelectTable(astTableWithAsOf(t, p1.dt))
require.NoError(t, err)
require.Equal(t, processor.GetStalenessReadTS(), p1.ts)
}

This comment was marked as outdated.

Copy link
Member

@ekexium ekexium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest LGTM

Comment on lines +73 to +75
// 1356998400000 ms = 2013-01-01T00:00:00Z, a reasonable lower bound for any TiDB TSO
physicalMS := oracle.ExtractPhysical(tso)
if physicalMS <= 1356998400000 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to extract this to a constant

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ekexium, nolouch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 16, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 16, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-04 03:55:06.066478408 +0000 UTC m=+330350.644557592: ☑️ agreed by nolouch.
  • 2026-03-16 07:55:59.563763442 +0000 UTC m=+170886.651420989: ☑️ agreed by ekexium.

@madhavramesh
Copy link
Author

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 23, 2026

@madhavramesh: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@tiprow
Copy link

tiprow bot commented Mar 23, 2026

@madhavramesh: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 24, 2026

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

📖 For more info, you can check the "Contribute Code" section in the development guide.

@cfzjywxk
Copy link
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 24, 2026
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 68.75000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.1785%. Comparing base (7b59a24) to head (6c20eee).
⚠️ Report is 176 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66643        +/-   ##
================================================
- Coverage   77.6779%   76.1785%   -1.4995%     
================================================
  Files          2006       1943        -63     
  Lines        548699     565385     +16686     
================================================
+ Hits         426218     430702      +4484     
- Misses       120821     132940     +12119     
- Partials       1660       1743        +83     
Flag Coverage Δ
integration 40.9294% <68.7500%> (-7.2561%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 46.3612% <ø> (-14.5077%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nolouch
Copy link
Member

nolouch commented Mar 24, 2026

/retest-required

@tiprow
Copy link

tiprow bot commented Mar 24, 2026

@madhavramesh: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 6c20eee link true /test fast_test_tiprow
tidb_parser_test 6c20eee link true /test tidb_parser_test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 24, 2026

@madhavramesh: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-build-next-gen 6c20eee link true /test pull-build-next-gen
idc-jenkins-ci-tidb/build 6c20eee link true /test build
idc-jenkins-ci-tidb/unit-test 6c20eee link true /test unit-test
pull-unit-test-next-gen 6c20eee link true /test pull-unit-test-next-gen

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved contribution This PR is from a community contributor. do-not-merge/needs-tests-checked do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. lgtm ok-to-test Indicates a PR is ready to be tested. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting TSO in AS OF TIMESTAMP clause

4 participants