Count a dead letter by when it was kept, so one kept late still counts (issue 440)
The give-up time is not newer for every letter kept: a notice that could not be kept is offered again a minute later, so a later give-up can be kept first and the one after it read as not fresh. The stored time rises with the stream's sequence. A consumer whose letters vanish between the two reads is left out of the look instead of counted as a look, and the skip of a token-less max-deliveries advisory now has a test of its own.
This commit is contained in:
@@ -80,8 +80,8 @@ type signalFacts struct {
|
||||
// deadLetters are how many messages DEAD_LETTERS holds per consumer, by `<stream>.<consumer>`
|
||||
// (novox/hq issue 330): each consumer's max-deliveries condition is open while it holds any.
|
||||
deadLetters map[string]int
|
||||
// deadLettersNewest is when each of those consumers last gave up on a message DEAD_LETTERS still
|
||||
// holds: the condition counts the messages given up on, not the looks (novox/hq issue 440).
|
||||
// deadLettersNewest is when DEAD_LETTERS kept the newest message it holds for each of those
|
||||
// consumers: the condition counts the messages given up on, not the looks (novox/hq issue 440).
|
||||
deadLettersNewest map[string]time.Time
|
||||
advisoriesErr error
|
||||
|
||||
@@ -355,6 +355,13 @@ func (w *watchdogs) gather(ctx context.Context) *signalFacts {
|
||||
}
|
||||
if f.advisoriesErr == nil && len(f.deadLetters) > 0 {
|
||||
f.deadLettersNewest, f.advisoriesErr = link.NewestDeadLetters(w.js.Context(), f.deadLetters)
|
||||
for key := range f.deadLetters {
|
||||
if _, ok := f.deadLettersNewest[key]; !ok && f.advisoriesErr == nil {
|
||||
// Delivered again or dropped between the two reads: left out of this look, rather than
|
||||
// observed without a time and counted as a look (novox/hq issue 440).
|
||||
delete(f.deadLetters, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
f.handActs, f.handActsErr = w.gatherHandActs(ctx, now)
|
||||
f.facts.taken, _, f.facts.began, f.facts.err = exportedFacts.last()
|
||||
|
||||
Reference in New Issue
Block a user