-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
triedb/pathdb: fix async node buffer diskroot mismatches when journaling #2083
Conversation
1ed7fef
to
e718c73
Compare
// to disk. | ||
type asyncnodebuffer struct { | ||
mux sync.RWMutex | ||
current *nodecache | ||
background *nodecache | ||
isFlushing atomic.Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think need a stop
flag to stop flush when call waitAndStopFlush
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, fixed
e718c73
to
96cc4e7
Compare
a.stopFlushing.Store(true) | ||
if a.isFlushing.Load() { | ||
time.Sleep(time.Second) | ||
log.Info("waiting background memory table flushed into disk") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Warn is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
4be0fce
to
87d4e02
Compare
87d4e02
to
d4f4db1
Compare
5c1ff4a
to
34f34f6
Compare
Description
When running
TestJournal
UT intrie/triedb/pathdb
, there is a certain probability that this error will occur:Invalid state, err: state 0xdda0214f6c0c6ea546cdbf3db74a31f8337a01b41908b3b8ea27a8fde0011294 is not available
.The reason of this error is that the journal loaded from disk is wrong, the error message of
loadJournal
function:unmatched journal want c3bd21026750db0009399463f5947e1663c7057cb4aaabeb0b39ed68dedd4d0b got 6d574af1033459ae676316a1262a5d89edb7bbd515ecd253b4319a3161093153
.Rationale
When geth calls
Journal
function to commit entire diff hierarchy to disk into a single journal entry, the flush process ofasyncnodebuffer
maybe doesn't end, so we should stop, wait it and journal.Example
N/A
Changes
Notable changes: