Skip to content

processor: export the final partial batch on shutdown - #874

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/processor-shutdown-flush-final-batch
Open

processor: export the final partial batch on shutdown#874
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/processor-shutdown-flush-final-batch

Conversation

@damilolaedwards

Copy link
Copy Markdown

The batch builder holds accumulated items in an in-memory batch until they reach the export size or the flush timer fires. On shutdown the builder ran in a goroutine that was never waited on, and drainQueue only waited on the queue and the worker channel, not on that in-memory batch.

As a result close(stopWorkersCh) raced the builder: the builder could exit without flushing, or its final batch could sit in the worker channel while the workers stopped. Any batch smaller than the export size, which is the common case on a graceful restart, was silently dropped with no failure recorded.

This tracks the batch builder with its own wait group and reorders shutdown: close the queue, wait for the builder to flush its final batch, wait for the workers to pick up every handed-off batch, and only then stop the workers. In-flight exports still complete before Shutdown returns.

Tests: adds a shutdown test over one and four workers asserting the final partial batch is always exported. Ran the full processor suite repeatedly under the race detector.

The batch builder holds accumulated items in an in-memory batch until they reach
the export size or the flush timer fires. On shutdown the builder ran in a
goroutine that was never waited on, and drainQueue only waited on the queue and
the worker channel, not on that in-memory batch. As a result close(stopWorkersCh)
raced the builder: the builder could exit without flushing, or its final batch
could sit in the worker channel while the workers stopped. Any batch smaller
than the export size, which is the common case on a graceful restart, was
silently dropped with no failure recorded.

Track the batch builder with its own wait group and reorder shutdown: close the
queue, wait for the builder to flush its final batch, wait for the workers to
pick up every handed-off batch, and only then stop the workers. In-flight
exports still complete before Shutdown returns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant