Skip to content
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
8 changes: 2 additions & 6 deletions ledger/acctonline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,8 +1605,6 @@ func TestAcctOnlineTopBetweenCommitAndPostCommit(t *testing.T) {
postCommitUnlockedReleaseLock: make(chan struct{}),
postCommitEntryLock: make(chan struct{}),
postCommitReleaseLock: make(chan struct{}),
alwaysLock: false,
shouldLockPostCommit: false,
}

conf := config.GetDefaultLocal()
Expand All @@ -1632,7 +1630,7 @@ func TestAcctOnlineTopBetweenCommitAndPostCommit(t *testing.T) {
newBlockWithUpdates(genesisAccts, updates, totals, t, ml, i, oa)
}

stallingTracker.shouldLockPostCommit = true
stallingTracker.shouldLockPostCommit.Store(true)

updateAccountsRoutine := func() {
var updates ledgercore.AccountDeltas
Expand Down Expand Up @@ -1698,8 +1696,6 @@ func TestAcctOnlineTopDBBehindMemRound(t *testing.T) {
postCommitUnlockedReleaseLock: make(chan struct{}),
postCommitEntryLock: make(chan struct{}),
postCommitReleaseLock: make(chan struct{}),
alwaysLock: false,
shouldLockPostCommit: false,
}

conf := config.GetDefaultLocal()
Expand All @@ -1725,7 +1721,7 @@ func TestAcctOnlineTopDBBehindMemRound(t *testing.T) {
newBlockWithUpdates(genesisAccts, updates, totals, t, ml, i, oa)
}

stallingTracker.shouldLockPostCommit = true
stallingTracker.shouldLockPostCommit.Store(true)

updateAccountsRoutine := func() {
var updates ledgercore.AccountDeltas
Expand Down
2 changes: 1 addition & 1 deletion ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2192,8 +2192,8 @@ func testAcctUpdatesLookupRetry(t *testing.T, assertFn func(au *accountUpdates,
postCommitUnlockedReleaseLock: make(chan struct{}),
postCommitEntryLock: make(chan struct{}),
postCommitReleaseLock: make(chan struct{}),
alwaysLock: true,
}
stallingTracker.alwaysLock.Store(true)
ml.trackers.trackers = append([]ledgerTracker{stallingTracker}, ml.trackers.trackers...)

// kick off another round
Expand Down
14 changes: 7 additions & 7 deletions ledger/catchpointtracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,9 @@ type blockingTracker struct {
postCommitEntryLock chan struct{}
postCommitReleaseLock chan struct{}
committedUpToRound int64
alwaysLock bool
shouldLockPostCommit bool
shouldLockPostCommitUnlocked bool
alwaysLock atomic.Bool
shouldLockPostCommit atomic.Bool
shouldLockPostCommitUnlocked atomic.Bool
}

// loadFromDisk is not implemented in the blockingTracker.
Expand Down Expand Up @@ -815,15 +815,15 @@ func (bt *blockingTracker) commitRound(context.Context, trackerdb.TransactionSco

// postCommit implements entry/exit blockers, designed for testing.
func (bt *blockingTracker) postCommit(ctx context.Context, dcc *deferredCommitContext) {
if bt.alwaysLock || dcc.catchpointFirstStage || bt.shouldLockPostCommit {
if bt.alwaysLock.Load() || dcc.catchpointFirstStage || bt.shouldLockPostCommit.Load() {
bt.postCommitEntryLock <- struct{}{}
<-bt.postCommitReleaseLock
}
}

// postCommitUnlocked implements entry/exit blockers, designed for testing.
func (bt *blockingTracker) postCommitUnlocked(ctx context.Context, dcc *deferredCommitContext) {
if bt.alwaysLock || dcc.catchpointFirstStage || bt.shouldLockPostCommitUnlocked {
if bt.alwaysLock.Load() || dcc.catchpointFirstStage || bt.shouldLockPostCommitUnlocked.Load() {
bt.postCommitUnlockedEntryLock <- struct{}{}
<-bt.postCommitUnlockedReleaseLock
}
Expand Down Expand Up @@ -1004,8 +1004,8 @@ func TestCatchpointTrackerWaitNotBlocking(t *testing.T) {
writeStallingTracker := &blockingTracker{
postCommitUnlockedEntryLock: make(chan struct{}),
postCommitUnlockedReleaseLock: make(chan struct{}),
shouldLockPostCommitUnlocked: true,
}
writeStallingTracker.shouldLockPostCommitUnlocked.Store(true)
ledger.trackerMu.Lock()
ledger.trackers.mu.Lock()
ledger.trackers.trackers = append(ledger.trackers.trackers, writeStallingTracker)
Expand All @@ -1032,7 +1032,7 @@ func TestCatchpointTrackerWaitNotBlocking(t *testing.T) {
// consume to unblock
<-writeStallingTracker.postCommitUnlockedEntryLock
// disable further blocking
writeStallingTracker.shouldLockPostCommitUnlocked = false
writeStallingTracker.shouldLockPostCommitUnlocked.Store(false)

// wait the writeStallingTracker.postCommitUnlockedReleaseLock passes
wg.Wait()
Expand Down