Skip to content

fix(core/txpool/locals): close journal under lock in Stop to fix data race #35096 - #2539

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:port-geth-35096-locals-fix-data-race
Open

fix(core/txpool/locals): close journal under lock in Stop to fix data race #35096#2539
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:port-geth-35096-locals-fix-data-race

Conversation

@gzliudan

@gzliudan gzliudan commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Description

The local tx tracker's journal was previously closed inside the loop() goroutine via a defer. Because the journal can still be accessed concurrently by Track/TrackAll during shutdown, this created a data race on the underlying journal writer.

This change moves journal.close() out of the goroutine and into Stop(), where it runs deterministically after tracker.wg.Wait() and is guarded by tracker.mu.

Note: on dev-upgrade the load/setupWriter half of upstream PR ethereum#35096 was already present in Start() (journal is loaded and the writer is set up before the goroutine starts), so only the close-relocation half is ported here.

Ref: ethereum#35096

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b838a8c-0271-4959-9b2e-04e90f855216

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gzliudan
gzliudan force-pushed the port-geth-35096-locals-fix-data-race branch from ab760d7 to b512a45 Compare August 23, 2026 15:32
… race ethereum#35096

Port go-ethereum PR ethereum#35096. Move journal.close() from the loop goroutine's deferred call into Stop(), guarded by tracker.mu, so the journal is deterministically closed after wg.Wait() instead of racing with concurrent Track/TrackAll access during shutdown. The load/setupWriter half was already present in Start() on dev-upgrade.
@gzliudan
gzliudan force-pushed the port-geth-35096-locals-fix-data-race branch from b512a45 to 141352c Compare August 24, 2026 10:52
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