fix(shared-state): resend an ambiguous in-flight batch at most once

A flush whose reply timed out may have landed in Redis. The flusher
kept the batch and resent it every tick, which counted it many times.
A batch that never reached the wire is still kept. A batch that may
have landed is resent once and then dropped.
This commit is contained in:
2026-11-26 04:07:43 +00:00
parent b1fa1bee14
commit 6438a95a76
3 changed files with 132 additions and 3 deletions
+2 -2
View File
@@ -630,7 +630,7 @@ func TestSharedInflightFlushErrorRetains(t *testing.T) {
a.begin("p")
a.begin("p")
end()
store.setFailIncr(errors.New("redis down"))
store.setFailIncr(&notAppliedError{err: errors.New("redis down")})
la.refresh()
a.begin("p") // lands on top of the retained deltas
la.refresh()
@@ -717,7 +717,7 @@ func TestSharedStateNoIdleStopWithPendingDeltas(t *testing.T) {
l.nowFn = clk.now
l.every = 5 * time.Millisecond
in := newSharedInflight(l, []string{"p"}, 20*time.Minute)
store.setFailIncr(errors.New("redis down"))
store.setFailIncr(&notAppliedError{err: errors.New("redis down")})
in.begin("p")
clk.advance(sharedStateIdleStop + time.Second)
time.Sleep(50 * time.Millisecond)