Skip to content

branch-4.1: [fix](fe) Keep table version monotonic after truncate #66255 - #66593

Open
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-66255-branch-4.1
Open

branch-4.1: [fix](fe) Keep table version monotonic after truncate #66255#66593
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-66255-branch-4.1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #66255

MTMV snapshots for non-PCT base tables compare `(tableId,
tableVersion)`.
`TRUNCATE` keeps the table ID but reset the non-Cloud table version to
1,
so later writes could reuse a previously recorded snapshot and cause
AUTO
refresh to miss changed data.

**Root cause:** `InternalCatalog.truncateTableInternal()` replaced the
old
partitions and then called `OlapTable.resetVisibleVersion()`. A sequence
such
as version 3 -> TRUNCATE to 1 -> two writes to version 3 creates an ABA
collision for table-level snapshot consumers.

**Change Summary:**

| File | Change Description |
|------|--------------------|
| `InternalCatalog.java` | Increment the non-Cloud table version once
after whole-table or partition TRUNCATE; Cloud remains Meta
Service-managed |
| `OlapTable.java`, `TableAttributes.java` | Remove the TRUNCATE-only
version reset helpers |
| `TruncateTableCommandTest.java` | Verify whole-table and partition
TRUNCATE each advance the table version once |
| `test_truncate_table_mtmv.groovy` | Reproduce the non-PCT table
snapshot ABA while preserving the existing expected output |
| `truncate_version_reset.groovy` | Keep the SimpleAggCache regression
description consistent with monotonic versions |

**Design Rationale:** The table version represents table-level data
changes,
while PCT refresh separately compares partition ID and partition
version.
Reusing the existing table version avoids new persisted flags or
MTMV-specific
invalidation state. Live execution and journal replay use the same
locked path.
Cloud is skipped locally because `commit_partition` already advances and
returns the Meta Service table version.
@github-actions
github-actions Bot requested a review from yiguolei as a code owner August 10, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant