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

Rethrow on unknown exceptions in fetch handler #16554

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

ballard26
Copy link
Contributor

Exceptions from outside the Kafka handler context can bubble up to the catch present in the handler. This seems to be the way some subsystems communicate issues with the requests. There is no current listing of what exceptions subsystems may throw, if/how to recover from these exceptions, or if a fetch should end as a result of the exception. Hence for the time being the fetch impl will revert to the behavior of further bubbling up unknown exceptions to outside of the handler context.

Fixes #16532

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

  • none

Copy link
Member

@travisdowns travisdowns left a comment

Choose a reason for hiding this comment

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

Then doesn't this raise again the possible problem with exception safety and gates? As I recall we "proved" that one function couldn't throw an exception after the gate was entered in part because the main function that could throw was surrounded by log_exceptions.

@travisdowns
Copy link
Member

Exceptions from outside the Kafka handler context can bubble up to the catch present in the handler.

This wasn't clear to me: is the "catch present in the handler" the one in the fetch handler log_exceptions or something else? From "outisde the handler context" do you mean from lower level stuff called by the handler?

Exceptions from outside the Kafka handler context can bubble up to the
catch present in the handler. This seems to be the way some subsystems
communicate issues with the requests. There is no current listing of
what exceptions subsystems may throw, if/how to recover from these
exceptions, or if a fetch should end as a result of the exception. Hence
for the time being the fetch impl will revert to the behavior of further
bubbling up unknown exceptions to outside of the handler context.
Copy link
Member

@travisdowns travisdowns left a comment

Choose a reason for hiding this comment

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

LGTM

@piyushredpanda piyushredpanda merged commit 6488da6 into redpanda-data:dev Feb 23, 2024
16 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x


// Send abort signal to workers and wait for all workers to end before
// returning.
co_await abort_workers().finally(
[this] { return _workers_gate.close(); });

if (_thrown_exception) {
std::rethrow_exception(_thrown_exception);
Copy link
Member

@dotnwat dotnwat Feb 23, 2024

Choose a reason for hiding this comment

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

@ballard26 should this eat the exception pointer like std::rethrow_exception(std::exchange(_thrown_exception, {})); or is this sort of the end-of-the-road for the handler and we'll not be examining _thrown_exception again in the same context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, not sure what we'd gain by doing so. And at this point the exception thrown isn't caught by the fetch executor so during the stack unwinding the fetch executor and hence _thrown_exception will be freed so it shouldn't matter. Beyond that std::exception_ptr can roughly be treated as a shared pointer according to the standard and should remain valid even if rethrown.

Copy link
Member

Choose a reason for hiding this comment

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

executor so during the stack unwinding the fetch executor and hence _thrown_exception will be freed so it shouldn't matter.

Ah, right. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants