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

tests: debug logging for TestVotersReloadFromDiskAfterOneStateProofCommitted #6088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,18 @@ func makeMockLedgerForTrackerWithLogger(t testing.TB, inMemory bool, initialBloc
Totals: totals,
}
}
return &mockLedgerForTracker{dbs: dbs, log: l, filename: fileName, inMemory: inMemory, blocks: blocks, deltas: deltas, consensusParams: config.Consensus[consensusVersion], consensusVersion: consensusVersion, accts: accts[0]}
ml := &mockLedgerForTracker{
dbs: dbs,
log: l,
filename: fileName,
inMemory: inMemory,
blocks: blocks,
deltas: deltas, consensusParams: config.Consensus[consensusVersion],
consensusVersion: consensusVersion,
accts: accts[0],
trackers: trackerRegistry{log: l},
}
return ml

}

Expand Down Expand Up @@ -160,6 +171,7 @@ func (ml *mockLedgerForTracker) fork(t testing.TB) *mockLedgerForTracker {
filename: fn,
consensusParams: ml.consensusParams,
consensusVersion: ml.consensusVersion,
trackers: trackerRegistry{log: dblogger},
}
for k, v := range ml.accts {
newLedgerTracker.accts[k] = v
Expand Down
1 change: 1 addition & 0 deletions ledger/blockqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func TestBlockQueueSyncerDeletion(t *testing.T) {
l := &Ledger{
log: log,
blockDBs: blockDBs,
trackers: trackerRegistry{log: log},
}
if test.tracker != nil {
l.trackers.trackers = append(l.trackers.trackers, test.tracker)
Expand Down
7 changes: 5 additions & 2 deletions ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ func (l *Ledger) reloadLedger() error {
blockListeners := make([]ledgercore.BlockListener, 0, len(l.notifier.listeners))
blockListeners = append(blockListeners, l.notifier.listeners...)

// close the trackers.
l.trackers.close()
// close the trackers if the registry was already initialized: opening a new ledger calls reloadLedger
// and there is nothing to close. Registry's logger is not initialized yet so close cannot log.
if l.trackers.trackers != nil {
l.trackers.close()
}

// init block queue
var err error
Expand Down
1 change: 1 addition & 0 deletions ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3415,6 +3415,7 @@ func TestLedgerRetainMinOffCatchpointInterval(t *testing.T) {
l := &Ledger{}
l.cfg = cfg
l.archival = cfg.Archival
l.trackers.log = logging.TestingLog(t)

for i := 1; i <= blocksToMake; i++ {
minBlockToKeep := l.notifyCommit(basics.Round(i))
Expand Down
9 changes: 9 additions & 0 deletions ledger/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@
// Dropping this dcc allows the blockqueue syncer to continue persisting other blocks
// and ledger reads to proceed without being blocked by trackerMu lock.
tr.accountsWriting.Done()
tr.log.Debugf("trackerRegistry.scheduleCommit: deferredCommits channel is full, skipping commit for (%d-%d)", dcc.oldBase, dcc.oldBase+basics.Round(dcc.offset))
}
}
}
Expand All @@ -491,22 +492,27 @@
}

func (tr *trackerRegistry) close() {
tr.log.Debugf("trackerRegistry is closing")
if tr.ctxCancel != nil {
tr.ctxCancel()
}

// close() is called from reloadLedger() when and trackerRegistry is not initialized yet
if tr.commitSyncerClosed != nil {
tr.log.Debugf("trackerRegistry is waiting for accounts writing to complete")
tr.waitAccountsWriting()
// this would block until the commitSyncerClosed channel get closed.
<-tr.commitSyncerClosed
tr.log.Debugf("trackerRegistry done waiting for accounts writing")
}

tr.log.Debugf("trackerRegistry is closing trackers")
for _, lt := range tr.trackers {
lt.close()
}
tr.trackers = nil
tr.accts = nil
tr.log.Debugf("trackerRegistry has closed")
}

// commitSyncer is the syncer go-routine function which perform the database updates. Internally, it dequeues deferredCommits and
Expand All @@ -525,11 +531,13 @@
}
case <-tr.ctx.Done():
// drain the pending commits queue:
tr.log.Debugf("commitSyncer is closing, draining the pending commits queue")
drained := false
for !drained {
select {
case <-deferredCommits:
tr.accountsWriting.Done()
tr.log.Debugf("commitSyncer drained a pending commit")

Check warning on line 540 in ledger/tracker.go

View check run for this annotation

Codecov / codecov/patch

ledger/tracker.go#L540

Added line #L540 was not covered by tests
default:
drained = true
}
Expand Down Expand Up @@ -648,6 +656,7 @@
lt.postCommitUnlocked(tr.ctx, dcc)
}

tr.log.Debugf("commitRound completed for (%d-%d)", dbRound, dbRound+basics.Round(offset))
return nil
}

Expand Down
Loading