Skip to content

Commit

Permalink
Fix flapping test
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Jan 30, 2022
1 parent b38ced5 commit 8815072
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions server/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4900,9 +4900,8 @@ func (o *consumerFileStore) UpdateDelivered(dseq, sseq, dc uint64, ts int64) err
if p = o.state.Pending[sseq]; p != nil {
p.Sequence, p.Timestamp = dseq, ts
}
}
// Add to pending if needed.
if p == nil {
} else {
// Add to pending.
o.state.Pending[sseq] = &Pending{dseq, ts}
}
// Update delivered as needed.
Expand Down
11 changes: 9 additions & 2 deletions server/norace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3332,7 +3332,8 @@ func TestNoRaceJetStreamClusterCorruptWAL(t *testing.T) {
}
}
// Make sure acks processed.
nc.Flush()
time.Sleep(200 * time.Millisecond)
nc.Close()

// Check consumer consistency.
checkConsumerWith := func(delivered, ackFloor uint64, ackPending int) {
Expand Down Expand Up @@ -3383,6 +3384,7 @@ func TestNoRaceJetStreamClusterCorruptWAL(t *testing.T) {
node := o.raftNode().(*raft)
fs := node.wal.(*fileStore)
fcfg, cfg := fs.fcfg, fs.cfg.StreamConfig
// Stop all the servers.
c.stopAll()

// Manipulate directly with cluster down.
Expand Down Expand Up @@ -3451,8 +3453,13 @@ func TestNoRaceJetStreamClusterCorruptWAL(t *testing.T) {
state = fs.State()
fs.Truncate(state.FirstSeq)

sub, err = js.PullSubscribe("foo", "dlc")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}

// This will cause us to stepdown and truncate our WAL.
fetchMsgs(t, sub, 100, 50*time.Millisecond)
fetchMsgs(t, sub, 100, 5*time.Second)

checkFor(t, 20*time.Second, 500*time.Millisecond, func() error {
// Make sure we changed leaders.
Expand Down

0 comments on commit 8815072

Please sign in to comment.