databendlabs / databend

๐——๐—ฎ๐˜๐—ฎ, ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ & ๐—”๐—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.88k stars 751 forks source link

fix: purge may not work on tables after a flash back operation #16812

Closed SkyFan2002 closed 1 week ago

SkyFan2002 commented 1 week ago

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

Summary

On tables that have undergone a FLASHBACK operation, this assumption is broken:

// Take the prev snapshot as base snapshot to avoid get orphan snapshot.

In this PR, the garbage collection root is determined by starting from the current snapshot and traversing backward to the target time point using the prev relation between snapshots. This approach enhances safety (allowing tables modified by the ALTER ... FLASHBACK operation to be handled correctly) but may require traversing a (much) longer history of the table being purged.

Tests

Type of change


This change isโ€‚Reviewable

dantengsky commented 1 week ago

LGTM Maybe need to add some notes on possible impacts to the summary.

PR summary updated, pls let me know if there are any other concerns.