Skip to content

fix: HLC is ahead of wall clock. iscp failed to update - #24765

Merged
mergify[bot] merged 9 commits into
matrixorigin:mainfrom
cpegeric:iscp_clock_mismatch
Jun 2, 2026
Merged

fix: HLC is ahead of wall clock. iscp failed to update#24765
mergify[bot] merged 9 commits into
matrixorigin:mainfrom
cpegeric:iscp_clock_mismatch

Conversation

@cpegeric

@cpegeric cpegeric commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24764

What this PR does / why we need it:

Avoid using wall clock and use HLC as a common time.

ISCP failed to update when startTs > 0 and HLC is ahead of wall clock.

@cpegeric
cpegeric requested a review from XuPeng-SH as a code owner June 1, 2026 13:03
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request Changes — one blocking issue

The fix for HandleGetChangedTableList is correct and necessary, but the same bug class exists in HandleBackup and should be fixed here too.

🔴 Must fix: HandleBackup at handle_debug.go:683 uses wall-clock TS

// handle_debug.go:683 (current code, outside the diff)
backupTime := time.Now().UTC()
currTs := types.BuildTS(backupTime.UnixNano(), 0) // ❌ wall clock

This has the exact same bug that this PR fixes in HandleGetChangedTableList. When HLC advances past wall clock (due to logtail replay or cross-node sync), currTs will be less than the true HLC, meaning:

  1. ForceCheckpoint(ctx, currTs) only flushes up to the wall clock timestamp — committed data between wall clock and HLC may be omitted
  2. If the backup tool reads checkpoint data using a higher TS, data committed between wall clock and HLC is missing from the backup

The file already has the correct pattern in HandleForceCheckpoint (line 655):

now, err := h.db.TxnMgr.Now() // ✅ HLC

Fix: change line 683 to use h.db.TxnMgr.Now() instead of BuildTS(time.Now().UTC().UnixNano(), 0).


Comment (non-blocking): HandleDiskCleaner at handle_debug.go:890

ts := types.BuildTS(time.Now().UTC().UnixNano()-int64(ttl), 0)

This uses wall clock for a TTL threshold compared against HLC checkpoint endTS. When HLC > wall clock, the threshold is lower than intended, resulting in less data being cleaned — so it errs on the safe side (over-retention). This is a resource/efficiency issue rather than a correctness one, but worth fixing for consistency.


Summary

Item Verdict
HandleGetChangedTableList fix ✅ Correct
HandleBackup wall-clock bug 🔴 Must fix in this PR
HandleDiskCleaner TTL 🟡 Non-blocking comment
Test coverage ⚠️ No regression test added

@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Jun 2, 2026
@mergify

mergify Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-02 16:03 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-06-02 17:27 UTC · at 6bf78e01d3cdd72230cb8a27c216ed75865b67d2 · squash

This pull request spent 1 hour 24 minutes 41 seconds in the queue, including 1 hour 22 minutes 40 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

@cpegeric

cpegeric commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio refresh

@mergify

mergify Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

refresh

✅ Pull request refreshed

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants