Skip to content
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

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

dt
Copy link
Member

@dt dt commented Sep 7, 2023

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 when flushBuffer explicitly calls sip.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 causes flushBuffer to return early, without calling Flush() 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 in flushBuffer so that it is always run, including before early returns, ensuring that flushBuffer never returns while its batcher has in-flight requests pending.

While I'm here: removed the unused error return from Reset().

@dt dt requested review from stevendanna and msbutler September 7, 2023 20:59
@dt dt requested a review from a team as a code owner September 7, 2023 20:59
@blathers-crl
Copy link

blathers-crl bot commented Sep 7, 2023

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.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@dt
Copy link
Member Author

dt commented Sep 7, 2023

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 7, 2023

Build failed (retrying...):

@dt
Copy link
Member Author

dt commented Sep 8, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 8, 2023

Already running a review

@craig
Copy link
Contributor

craig bot commented Sep 8, 2023

Build succeeded:

@craig craig bot merged commit dbab89e into cockroachdb:master Sep 8, 2023
@dt dt deleted the ingest-span-race branch September 8, 2023 10:53
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.

roachtest: c2c/shutdown/src/coordinator failed streamingccl: span use-after-finish
3 participants