Skip to content

fix: transient table does not work as expected inside explicit transaction #18215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dantengsky
Copy link
Member

@dantengsky dantengsky commented Jun 23, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Enhanced Timestamp Handling in Explicit Transactions

To ensure vacuum operation safety, a critical invariant should be maintained (among others): any successfully committed table snapshot must have all new table data (segments, blocks, indexes) timestamped greater than or equal to its direct predecessor snapshot's timestamp.

The current implementation maintains this invariant but is overly conservative and may cause unexpected exceptions during transient table mutations within an explicit transaction (issue #18159). This issue also occurs when data_retention_time_in_days is set to 0.

This PR:

  • Tracks logical transaction begin timestamps for each table within an explicit transaction
  • Ensures all new table data during an explicit transaction is marked with timestamps greater than or equal to this logical begin timestamp
  • Implements conflict resolution that aborts the current transaction if an already committed conflicting table snapshot has a timestamp greater than the logical transaction begin timestamp of the same table, preserving vacuum safety
  • Improves error messages to better describe failure causes, particularly warning users that concurrent modifications to transient tables or tables with minimal retention periods are prone to unresolvable conflicts, with guidance on appropriate adjustments

Adjust Auto-Vacuum Trigger Timing

Auto-vacuum execution now occurs only after successful transaction commit.

Table Meta Timestamp Cache Clearing

Added proactive clearing of table meta timestamp cache before hooks(compaction, index refreshing) execution to resolve issues reported in #18167.

Code Organization Improvements

Test-specific code has been properly annotated with #[cfg(test)] to ensure it's not used outside unit tests, and fixed previous misuses of these test utilities.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Jun 23, 2025
@dantengsky dantengsky force-pushed the fix-transient-table-within-explicit-txn-rnd2 branch 2 times, most recently from 75af8a5 to bbb1d17 Compare June 24, 2025 16:18
@databendlabs databendlabs deleted a comment from github-actions bot Jun 24, 2025
@databendlabs databendlabs deleted a comment from github-actions bot Jun 24, 2025
@dantengsky dantengsky marked this pull request as ready for review June 25, 2025 06:59
@dantengsky dantengsky marked this pull request as draft June 25, 2025 07:00
@dantengsky dantengsky force-pushed the fix-transient-table-within-explicit-txn-rnd2 branch from 91ba766 to 69d1923 Compare June 26, 2025 07:10
@databendlabs databendlabs deleted a comment from github-actions bot Jun 26, 2025
@dantengsky dantengsky added the ci-cloud Build docker image for cloud test label Jun 27, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-18215-aee0205-1751013657

note: this image tag is only available for internal use.

@dantengsky dantengsky force-pushed the fix-transient-table-within-explicit-txn-rnd2 branch from c6b6446 to 258b8df Compare June 27, 2025 12:35
@databendlabs databendlabs deleted a comment from github-actions bot Jun 27, 2025
@dantengsky dantengsky marked this pull request as ready for review June 28, 2025 18:29
@dantengsky dantengsky requested a review from SkyFan2002 June 28, 2025 18:29
@BohuTANG BohuTANG added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Jun 30, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-18215-ad12d09-1751247039

note: this image tag is only available for internal use.

@dantengsky dantengsky added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Jun 30, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-18215-42c6013-1751285258

note: this image tag is only available for internal use.

@databendlabs databendlabs deleted a comment from github-actions bot Jun 30, 2025
@dantengsky dantengsky merged commit 7bc9243 into databendlabs:main Jun 30, 2025
250 of 254 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cloud Build docker image for cloud test pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: auto-compaction of transient tables fails silently bug: transient table no work as expected inside explicit transaction
3 participants