Repository navigation
[Rust] Drain ack callbacks when closing a failed stream - #1193
Draft
dimitrije-djordjevic-db wants to merge 3 commits into
Draft
dimitrije-djordjevic-db wants to merge 3 commits into
dimitrije-djordjevic-db wants to merge 3 commits into
Conversation
When a stream fails, close() must still wait for the queued on_error callbacks before it returns. Add regression tests: close waits for them and returns Ok; it respects a finite callback budget and an explicit None; a cancelled close leaves the drain to the next close; the budget is separate from flush_timeout_ms; the same holds after a non-retryable failure with recovery on; drop doesn't wait; and a failed 1-lane mux drains at close and returns the lane failure. The close tests fail until close() drains the callbacks on a failed stream. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>
A failed stream is closed by its supervisor, which queues one on_error callback per pending record. close() then saw the closed flag and returned at once, so the callbacks it had not run yet were dropped when the stream was freed. On that path close() now stops the supervisor, so every on_error is queued, then drains the callback task within callback_max_wait_time_ms, as a normal close does. It still returns Ok(()), and a second close after a completed one still does nothing. Fixes #1191 Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Dimitrije Đorđević <dimitrije.djordjevic@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
ZerobusStream::close()on a stream that has already failed now waits for pending ack callbacks before it returns. Closes #1191.When a stream fails, the SDK queues one
on_errorcall per pending record. Before this change,close()on the failed stream returnedOkat once and never waited for them. Dropping or freeing the stream then aborted the callback task, and the queuedon_errorcalls were lost. Nowclose()stops the supervisor and drains the callbacks, bounded bycallback_max_wait_time_msas on a normal close. It still returnsOk, as documented, but it can now take up tocallback_max_wait_time_mswhile callbacks finish. Multiplexed streams already drained every lane, so they are unchanged.Why: a caller that uses
on_errorto learn which records failed could miss some of them. This affects every SDK with an ack callback.How is this tested?
New tests in
rust/tests/src/rust_tests.rs(callback_tests). They fail before the fix and pass after it:close()on a failed stream waits while anon_erroris blocked, then every queuedon_errorhas arrived when it returns.Guard tests, which pass before and after: dropping a failed stream does not wait for callbacks, and a failed multiplexed stream drains its callbacks on close.
make test(the full feature matrix) andmake lintpass.This pull request and its description were written by Isaac.