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

fix: Correctly raise producer exceptions #660

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

giuseppelillo
Copy link
Contributor

@giuseppelillo giuseppelillo commented Jun 15, 2023

Fix a bug in which producer exceptions were raised inside the I/O thread instead of the main one.

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jun 15, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 86fac38
Status: ✅  Deploy successful!
Preview URL: https://0b2a9a99.karapace.pages.dev
Branch Preview URL: https://giuseppelillo-fix-producer-e.karapace.pages.dev

View logs

karapace/backup/api.py Outdated Show resolved Hide resolved
@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch from 2d5ab72 to 18ee1b9 Compare June 15, 2023 13:30


def _handle_producer_send(
instruction: ProducerSend,
producer: KafkaProducer,
) -> None:
check_producer_exception()
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Let's document (with comment) the reason why we're also doing this here. Is it to reach a stop quicker than waiting for the call in restore_backup()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this call is made here to avoid calling send() for all messages if there was an error earlier.

Copy link
Contributor

Choose a reason for hiding this comment

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

This still applies with the new change-set. For a reader of the code, it won't be obvious why the check method is called in two different places. I think it's important to document, with a comment in the code, why we make the post-send call: it's an optimization. And that one of the calls is fundamental for correct behavior, and one is not.

karapace/backup/api.py Outdated Show resolved Hide resolved
@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch from 18ee1b9 to f2e65a0 Compare June 15, 2023 13:39
karapace/backup/api.py Outdated Show resolved Hide resolved
@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch from f2e65a0 to eb19aa3 Compare June 15, 2023 15:57
@giuseppelillo giuseppelillo marked this pull request as ready for review June 16, 2023 08:06
@giuseppelillo giuseppelillo requested review from a team as code owners June 16, 2023 08:06
@giuseppelillo giuseppelillo changed the title fix: raise producer exception fix: Correctly raise producer exceptions Jun 16, 2023
karapace/backup/api.py Outdated Show resolved Hide resolved
karapace/backup/api.py Outdated Show resolved Hide resolved
karapace/backup/api.py Outdated Show resolved Hide resolved
@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch 3 times, most recently from 434ea31 to c51e3a4 Compare June 16, 2023 10:51
_producer_exception = None

def _producer_error_callback(exception: Exception) -> None:
LOG.error("Producer error: %r", exception)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("Producer error: %r", exception)
LOG.error("Producer error callback", exc_info=exception)

@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch 2 times, most recently from 17d53ed to 5f7e5e3 Compare June 16, 2023 12:17
karapace/backup/api.py Outdated Show resolved Hide resolved
@giuseppelillo giuseppelillo force-pushed the giuseppelillo/fix-producer-error branch from 5f7e5e3 to cd43ef6 Compare June 16, 2023 12:25
jjaakola-aiven
jjaakola-aiven previously approved these changes Jun 16, 2023
karapace/backup/api.py Outdated Show resolved Hide resolved
karapace/backup/api.py Outdated Show resolved Hide resolved
Fix a bug in which producer exceptions were raised inside the
I/O thread instead of the main one.
@jjaakola-aiven jjaakola-aiven merged commit ec75a34 into main Jun 16, 2023
11 checks passed
@jjaakola-aiven jjaakola-aiven deleted the giuseppelillo/fix-producer-error branch June 16, 2023 13:31
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.

None yet

3 participants