Start no prefix flush after the stop deadline (closes #188)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
When a write ran past the stop deadline, a full batch's wake-up or a tick could wait beside Stop's context. The flush goroutine's select picked one of them at random, so about half the time it wrote that batch after the deadline. That was the intermittent failure of TestPrefixHandlerSkipsItsLastWriteAfterTheStopDeadline. The flush goroutine now takes a waiting stop first. A new test hands over a full batch while a write is held; it fails about half its runs on the old code. TestPrefixHandlerSkipsItsLastWriteAfterTheStopDeadline and TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten also failed when the flush timer fired between two of their steps. Both now give the handler a timer interval longer than the test. Model: opus-5-5
This commit was merged in pull request #190.
This commit is contained in:
@@ -341,15 +341,14 @@ func TestPrefixHandlerWritesManyTableChangesOverSeveralFlushes(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten stops a prefix handler,
|
||||
// with no deadline, whose routing table holds more changed pairs than two
|
||||
// writes take. Its last flush writes one write's worth, so Stop must log the
|
||||
// pairs that no write took.
|
||||
// with no deadline, whose routing table holds more changed pairs than one write
|
||||
// takes. Its last flush writes one write's worth, so Stop must log the pairs
|
||||
// that no write took. The flush timer must not fire, or its writes could leave
|
||||
// no pairs for Stop to log.
|
||||
func TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// More than two writes take, so that pairs are left even when the flush
|
||||
// timer writes once before Stop.
|
||||
const pairs = 2*maxTableChangesPerWrite + 1
|
||||
const pairs = maxTableChangesPerWrite + 1
|
||||
|
||||
var logs bytes.Buffer
|
||||
|
||||
@@ -357,7 +356,7 @@ func TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten(t *testing.T) {
|
||||
table := routetable.New(routetable.Params{})
|
||||
announceManyPrefixes(table, pairs)
|
||||
|
||||
h := NewPrefixHandler(store, newErrorLogger(&logs), table)
|
||||
h := newPrefixHandler(store, newErrorLogger(&logs), table, longerThanAnyTest)
|
||||
h.Stop(t.Context())
|
||||
|
||||
written := 0
|
||||
|
||||
Reference in New Issue
Block a user