This commit is contained in:
rayoo 2026-05-21 21:54:14 -07:00 committed by GitHub
commit 672fb75de0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -196,12 +196,21 @@ func (tracker *TxTracker) loop() {
return nil
})
// Setup the writer for the upcoming transactions
if err := tracker.journal.setupWriter(); err != nil {
// Setup the writer for the upcoming transactions.
// Hold the mutex to avoid racing with recheck/TrackAll
// which also access journal.writer.
tracker.mu.Lock()
err := tracker.journal.setupWriter()
tracker.mu.Unlock()
if err != nil {
log.Error("Failed to setup the journal writer", "err", err)
return
}
defer tracker.journal.close()
defer func() {
tracker.mu.Lock()
tracker.journal.close()
tracker.mu.Unlock()
}()
}
var (
lastJournal = time.Now()