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

triedb/pathdb: fix async node buffer diskroot mismatches when journaling #2083

Merged
merged 3 commits into from
Dec 26, 2023

Conversation

sysvm
Copy link
Contributor

@sysvm sysvm commented Dec 18, 2023

Description

When running TestJournal UT in trie/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 of asyncnodebuffer maybe doesn't end, so we should stop, wait it and journal.

Example

N/A

Changes

Notable changes:

  • N/A

@sysvm sysvm force-pushed the fix_pathdb_journal branch from 1ed7fef to e718c73 Compare December 18, 2023 13:11
// to disk.
type asyncnodebuffer struct {
mux sync.RWMutex
current *nodecache
background *nodecache
isFlushing atomic.Bool
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, fixed

@sysvm sysvm added the r4r ready for review label Dec 18, 2023
@sysvm sysvm force-pushed the fix_pathdb_journal branch from e718c73 to 96cc4e7 Compare December 19, 2023 03:02
@sysvm sysvm changed the title fix: async node buffer diskroot mismatch when journal triedb/pathdb: fix async node buffer diskroot mismatches when journaling Dec 19, 2023
a.stopFlushing.Store(true)
if a.isFlushing.Load() {
time.Sleep(time.Second)
log.Info("waiting background memory table flushed into disk")
Copy link
Contributor

Choose a reason for hiding this comment

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

log.Warn is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@sysvm sysvm force-pushed the fix_pathdb_journal branch 2 times, most recently from 4be0fce to 87d4e02 Compare December 22, 2023 03:00
@sysvm sysvm force-pushed the fix_pathdb_journal branch from 87d4e02 to d4f4db1 Compare December 22, 2023 08:35
@sysvm sysvm force-pushed the fix_pathdb_journal branch from 5c1ff4a to 34f34f6 Compare December 25, 2023 08:31
@sysvm sysvm merged commit c255942 into develop Dec 26, 2023
5 checks passed
@sysvm sysvm deleted the fix_pathdb_journal branch December 27, 2023 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants