Fix for race and test for issue R.I. was seeing in nightly. Also fixed flappers.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2021-01-24 20:20:05 -08:00
parent a72ddedb55
commit 117607ef11
4 changed files with 47 additions and 17 deletions

View File

@@ -912,7 +912,10 @@ func (o *Consumer) deleteNotActive() {
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
for range ticker.C {
if ca := js.consumerAssignment(acc, stream, name); ca != nil {
js.mu.RLock()
ca := js.consumerAssignment(acc, stream, name)
js.mu.RUnlock()
if ca != nil {
s.Warnf("Consumer assignment not cleaned up, retrying")
meta.ForwardProposal(removeEntry)
} else {
@@ -1053,9 +1056,9 @@ func (o *Consumer) updateDelivered(dseq, sseq, dc uint64, ts int64) {
n += binary.PutUvarint(b[n:], dc)
n += binary.PutVarint(b[n:], ts)
o.node.Propose(b[:n])
} else {
o.store.UpdateDelivered(dseq, sseq, dc, ts)
}
// Update local state always.
o.store.UpdateDelivered(dseq, sseq, dc, ts)
}
// Lock should be held.

View File

@@ -171,7 +171,7 @@ type lps struct {
}
const (
minElectionTimeout = 350 * time.Millisecond
minElectionTimeout = 300 * time.Millisecond
maxElectionTimeout = 3 * minElectionTimeout
minCampaignTimeout = 50 * time.Millisecond
maxCampaignTimeout = 4 * minCampaignTimeout