Skip to content

Commit b4e9e04

Browse files
committed
fix race condition
1 parent db7c4d9 commit b4e9e04

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

long_running_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestLongRunningReplication(t *testing.T) {
3434
net.StopAndAssert(false)
3535
}
3636

37-
// Oh shoot, aws crashed node 3. will they recover....
3837
func TestLongRunningCrash(t *testing.T) {
3938
net := testutil.NewDefaultLongRunningNetwork(t, 10)
4039
for i, instance := range net.Instances {

testutil/long_running_network.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ func (n *LongRunningInMemoryNetwork) CrashNodes(nodeIndexes ...uint64) {
7171

7272
func (n *LongRunningInMemoryNetwork) RestartNodes(nodeIndexes ...uint64) {
7373
for _, idx := range nodeIndexes {
74+
n.lock.Lock()
7475
instance := n.Instances[idx]
76+
7577
nodeID := instance.E.ID
76-
logger := instance.l
7778
bb := instance.BB
7879
clonedWal := instance.WAL.Clone()
7980
clonedStorage := instance.Storage.Clone()
@@ -82,13 +83,14 @@ func (n *LongRunningInMemoryNetwork) RestartNodes(nodeIndexes ...uint64) {
8283
BlockBuilder: bb,
8384
ReplicationEnabled: true,
8485
MaxRoundWindow: longRunningMaxRoundWindow,
85-
Logger: logger,
86+
Logger: instance.l,
8687
WAL: clonedWal,
8788
Storage: clonedStorage,
8889
StartTime: instance.currentTime.Load(),
8990
})
9091

9192
n.Instances[idx] = newNode
93+
n.lock.Unlock()
9294
newNode.Start()
9395
}
9496
}

0 commit comments

Comments
 (0)