Make the routewatch tests pass on a loaded host (closes #213)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Five prefix handler tests gave HandleMessage two seconds to apply a full batch of 25,000 prefixes, which under the race detector on a loaded host takes longer. A test now waits up to stepTimeout, 15 seconds, for each step it expects. The slowest tests filled production limits, such as the peering handler's 500,000 paths. The peering handler now takes its path limit, and the prefix handler its limit on one write of the table's changes, as they take their timer interval. Those tests give small limits, and the tests of the maximum batch size lower it to one batch. This also fixes #215. The test helpers bound every wait, Stop included, so a test that hangs in one fails with its own message. Model: opus-5-5
This commit was merged in pull request #214.
This commit is contained in:
@@ -40,9 +40,13 @@ type ASHandler struct {
|
||||
db database.Store
|
||||
logger *logger.Logger
|
||||
|
||||
// batchMaxSize is asnBatchMaxSize. Only HandleMessage reads it, so a test
|
||||
// may lower it before it hands the handler a message.
|
||||
batchMaxSize int
|
||||
|
||||
// Batching. mu guards batch and writing only: the flush goroutine takes
|
||||
// the batch under mu and writes it after releasing mu, so HandleMessage
|
||||
// waits for a database write only while batch is at asnBatchMaxSize.
|
||||
// waits for a database write only while batch is at batchMaxSize.
|
||||
mu sync.Mutex
|
||||
batch []asnOp
|
||||
// writing is how many operations the flush goroutine took from batch
|
||||
@@ -79,12 +83,13 @@ func newASHandler(
|
||||
db database.Store, logger *logger.Logger, batchTimeout time.Duration,
|
||||
) *ASHandler {
|
||||
h := &ASHandler{
|
||||
db: db,
|
||||
logger: logger,
|
||||
batch: make([]asnOp, 0, asnBatchSize),
|
||||
batchFullCh: make(chan struct{}, 1),
|
||||
stopCh: make(chan context.Context, 1),
|
||||
done: make(chan struct{}),
|
||||
db: db,
|
||||
logger: logger,
|
||||
batchMaxSize: asnBatchMaxSize,
|
||||
batch: make([]asnOp, 0, asnBatchSize),
|
||||
batchFullCh: make(chan struct{}, 1),
|
||||
stopCh: make(chan context.Context, 1),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
h.batchTaken.L = &h.mu
|
||||
|
||||
@@ -127,7 +132,7 @@ func (h *ASHandler) HandleMessage(msg *ristypes.RISMessage) {
|
||||
// While the batch is at its maximum size, wait until the flush goroutine
|
||||
// takes it. Meanwhile the handler takes nothing off its queue, which
|
||||
// fills, and the streamer drops messages for it.
|
||||
for len(h.batch) >= asnBatchMaxSize {
|
||||
for len(h.batch) >= h.batchMaxSize {
|
||||
h.batchTaken.Wait()
|
||||
}
|
||||
|
||||
@@ -151,7 +156,7 @@ func (h *ASHandler) HandleMessage(msg *ristypes.RISMessage) {
|
||||
|
||||
// A full batch wakes the flush goroutine. If it is writing, the wake-up
|
||||
// waits in batchFullCh and the batch keeps growing until the write ends
|
||||
// or the batch reaches asnBatchMaxSize.
|
||||
// or the batch reaches batchMaxSize.
|
||||
if len(h.batch) >= asnBatchSize {
|
||||
select {
|
||||
case h.batchFullCh <- struct{}{}:
|
||||
|
||||
Reference in New Issue
Block a user