-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kv/bulk: ensure in-flight requests end on batcher reset #110218
Conversation
Release note: none. Epic: none.
Release note: none. Epic: none.
Release note: none. Epic: none.
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
TFTR! bors r+ |
Build failed (retrying...): |
bors r+ |
Already running a review |
Build succeeded: |
streamingest: ensure batcher is always reset
kv/bulk: ensure in-flight requests end on batcher reset
Previously if
streamIngestionProcessor.flushBuffer()
had started adding keys to a batcher, it was possible that that batcher had filled and triggered an async flush. Typically this async flush would be awaited whenflushBuffer
explicitly callssip.batcher.Flush()
immediately after the loop in which it adds keys. However, if one of the key additions returned an error, one of these async flushes could still be in-flight when that error causesflushBuffer
to return early, without callingFlush()
and waiting for it. Thus,flushBuffer
could return and in doing so finish its local tracing span, that it handed to the batcher and is being used to send its still ongoing async flush, resulting in that request then finding itself using a finished span, which is illegal.The changes here add waiting to inflight requests to
batcher.Reset()
, and then defer the reset of the batcher influshBuffer
so that it is always run, including before early returns, ensuring thatflushBuffer
never returns while its batcher has in-flight requests pending.While I'm here: removed the unused error return from
Reset()
.