You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Corrupted table history due to CREATE OR REPLACE TABLE & Snapshot Expiration at the same time #13651
It seems like running snapshot expiration and CREATE OR REPLACE TABLE at the same time can cause table history corruption. The following happens:
The base metadata, X, contains snapshots for expiration
The replace operation loads the metadata X and uses it as base
Snapshot expiration runs, creates metadata X+1, and commits it successfully, deleting old snapshots' data
The replace operation finishes, and commits it successfully, with what seems to be X as its base, instead of X+1. It seems like the replace operation ignores commit conflicts during the replace operation
Initial Observations
If I'm looking at this correctly, the code that commits the replace transaction seems to have a logic that looks like ignores changes done to the base metadata, here:
// because this is a replace table, it will always completely replace the table
// metadata. even if it was just updated.
if (base != underlyingOps.current()) {
this.base = underlyingOps.current(); // just refreshed
}
In our scenario, current seems to include the history before cleanup, while base after the lines above is actually the clean metadata without the snapshots that were just expired. When the commit occurs a few lines below, it seems like it commits the new metadata with the old history in it, causing the corruption.
Am I reading this correctly? What was the logic behind this? Is it only for efficiency reasons since there is no real need to handle commit conflicts in these cases as all data files are replaced?
On a sidenote
I know there are active mailing list discussions around this (thread), and also an issue that was closed recently about this subject (with @RussellSpitzer 's comment about corrupted metadata). Would love to hear your thoughts about possible next steps here.
Thanks!
Willingness to contribute
I can contribute a fix for this bug independently
I would be willing to contribute a fix for this bug with guidance from the Iceberg community
I cannot contribute a fix for this bug at this time
Reacted by Danny Mor, Nitzan Mousan and Omer Hadari
I think this was mentioned on the mailing list as well, but yes we definitely need to fix this. Even if we do change the behavior in the future that won't be for a long time and this is a bug now.
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
Activity
RussellSpitzer commentedon Aug 7, 2025
I think this was mentioned on the mailing list as well, but yes we definitely need to fix this. Even if we do change the behavior in the future that won't be for a long time and this is a bug now.
ggadon commentedon Aug 9, 2025
Opened a PR here: #13764
github-actions commentedon Feb 6, 2026
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
github-actions commentedon Feb 20, 2026
This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'