Skip to content

core/rawdb: allow head truncation below the tail of a newly aligned table - #35536

Open
0xSHKWON wants to merge 1 commit into
ethereum:masterfrom
0xSHKWON:fix-freezer-truncate-below-aligned-tail
Open

core/rawdb: allow head truncation below the tail of a newly aligned table#35536
0xSHKWON wants to merge 1 commit into
ethereum:masterfrom
0xSHKWON:fix-freezer-truncate-below-aligned-tail

Conversation

@0xSHKWON

Copy link
Copy Markdown
Contributor

The #35258 carve-out only holds while the new table is still empty, and bals stops being empty after the first frozen block. From then on a rewind below the alignment point fails with “truncation below tail” (the symptom of #35210), headerchain escalates it to log.Crit, and with the other tables already truncated, the freezer no longer opens on the next start.

Key the relaxation on the tail sitting at the table’s first stored item instead: an aligned table keeps that property for life, while a tail that has moved past it has genuinely pruned data below and is still rejected.

@0xSHKWON
0xSHKWON requested a review from rjl493456442 as a code owner August 13, 2026 20:32
@rjl493456442

Copy link
Copy Markdown
Member

Have you ever experienced with this symptom? Or it's just simulated by AI

@0xSHKWON

Copy link
Copy Markdown
Contributor Author

Not on a live node, I found it while reading the #35258 carve-out. But it’s mechanically reproducible: revert the freezer_table.go hunk and the test here fails with exactly this error.

if existing == hidden {
// Empty table means that it is newly added. Its tail would be
// at the head, so we have to align the table down to the new head.
// A table whose tail sits exactly at its first stored item has never had

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this fix is correct.

The actual issue is that the BAL table is initialized at the common head of the tables, with everything below it already pruned. If the freezer later needs to be truncated below that common head, there is simply nothing left to delete.

This is a very specific upgrade-path issue, and we don't want to make "truncate below tail" a generally valid operation.

existing == hidden is intended to identify empty tables. We shouldn't broaden that condition to cover additional cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT:

We should allow "truncate below tail" becomes valid across the different group. Let me figure out the better solution.

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.

2 participants