branch-4.1: [fix](fe) Keep table version monotonic after truncate #66255 - #66593
Open
github-actions[bot] wants to merge 1 commit into
Open
branch-4.1: [fix](fe) Keep table version monotonic after truncate #66255#66593github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #66255