Skip to content

Commit

Permalink
Fix a data race in app tests (#3269)
Browse files Browse the repository at this point in the history
## Summary

A test helper function `commitRound` accessed `l.trackers.lastFlushTime` without taking a lock. Fixed.

## Test Plan

```
go test ./ledger -run TestAppEmpty -race -count=50
ok      github.com/algorand/go-algorand/ledger  4.078s
```
  • Loading branch information
algorandskiy authored Dec 2, 2021
1 parent 54db1c7 commit 6657c2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ledger/applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import (
)

func commitRound(offset uint64, dbRound basics.Round, l *Ledger) {
l.trackers.mu.Lock()
l.trackers.lastFlushTime = time.Time{}
l.trackers.mu.Unlock()

l.trackers.scheduleCommit(l.Latest(), l.Latest()-(dbRound+basics.Round(offset)))
l.trackers.waitAccountsWriting()
}
Expand Down

0 comments on commit 6657c2b

Please sign in to comment.