Skip to content
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

core/rawdb, cmd, ethdb, eth: implement freezer tail deletion #23954

Merged
merged 10 commits into from
Mar 10, 2022
Prev Previous commit
Next Next commit
core/rawdb: remove unused code
  • Loading branch information
rjl493456442 committed Feb 18, 2022
commit 267eaa702272e39f908b650d273bc739ed7336ee
5 changes: 3 additions & 2 deletions core/rawdb/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ func (f *freezer) repair() error {
if head > items {
head = items
}
if table.tail() > tail {
tail = table.tail()
hidden := atomic.LoadUint64(&table.itemHidden)
if hidden > tail {
tail = hidden
}
}
for _, table := range f.tables {
Expand Down
9 changes: 1 addition & 8 deletions core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,6 @@ func (t *freezerTable) preopen() (err error) {
return err
}

// tail returns the index of the first stored item in the freezer table.
// It can also be interpreted as the number of items marked as deleted
// from the tail.
func (t *freezerTable) tail() uint64 {
return atomic.LoadUint64(&t.itemHidden)
}

// truncateHead discards any recent data above the provided threshold number.
func (t *freezerTable) truncateHead(items uint64) error {
t.lock.Lock()
Expand Down Expand Up @@ -822,7 +815,7 @@ func (t *freezerTable) retrieveItems(start, count, maxBytes uint64) ([]byte, []i
// has returns an indicator whether the specified number data is still accessible
// in the freezer table.
func (t *freezerTable) has(number uint64) bool {
return atomic.LoadUint64(&t.items) > number && t.tail() <= number
return atomic.LoadUint64(&t.items) > number && atomic.LoadUint64(&t.itemHidden) <= number
}

// size returns the total data size in the freezer table.
Expand Down