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: Improve Kafee exception handling #126

Merged
merged 12 commits into from
Dec 12, 2024

Conversation

jondthomas
Copy link
Contributor

@jondthomas jondthomas commented Dec 9, 2024

Related Ticket(s)

SIGNAL-7451

Checklist

Problem

We've noticed on wms-service that under high load, sometimes we get error messages in our consumers. These bubble up and trigger the exception handling of Broadway. This PR aims to more gracefully catch exits that occur in Task.await_many/2 and mark the messages as failed.

Details

There is also a shift in approach - instead of manually calling handle_failure and then returning the message in failed cases, I am opting to shift our usage to reflect the library. handle_failure is called by the library itself, so there's no need for Kafee to call it manually if we use Broadway.Message.failed/2

@jondthomas jondthomas requested a review from a team as a code owner December 9, 2024 22:08
@jondthomas jondthomas marked this pull request as draft December 9, 2024 22:18
Comment on lines +241 to +243
# Dialyzer can't recognize that :ok is a valid return type for this function
# due to the rescue clause in push_message/3
@dialyzer {:nowarn_function, do_consumer_work: 3}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the rescue on Kafee.Consumer.Adapter.push_message makes Dialyzer think that {:error, Exception.t()} is the only possible return... I've tried a couple different ways to fix without luck. Open to ideas

@jondthomas jondthomas marked this pull request as ready for review December 10, 2024 18:25
Copy link
Contributor

@kinson kinson left a comment

Choose a reason for hiding this comment

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

💥

lib/kafee/consumer/broadway_adapter.ex Show resolved Hide resolved
lib/kafee/consumer/broadway_adapter.ex Outdated Show resolved Hide resolved
lib/kafee/consumer/broadway_adapter.ex Show resolved Hide resolved
lib/kafee/consumer/broadway_adapter.ex Outdated Show resolved Hide resolved
@jondthomas jondthomas requested a review from kinson December 12, 2024 16:04
@jondthomas jondthomas merged commit fa5bd44 into main Dec 12, 2024
11 of 12 checks passed
@jondthomas jondthomas deleted the feat/AddMoreGranularBatchFailureHandling branch December 12, 2024 19:37
parkerd pushed a commit that referenced this pull request Dec 17, 2024
An automated release has been created for you.
---


## [3.5.1](v3.5.0...v3.5.1)
(2024-12-13)


### Bug Fixes

* Improve Kafee exception handling
([#126](#126))
([fa5bd44](fa5bd44))
* Update kafee consumer handle_failure/2 fn
([#119](#119))
([4c12df7](4c12df7))


### Miscellaneous

* Correct documentation to include start.count metric
([#125](#125))
([3ab284c](3ab284c))
* Sync files with stordco/common-config-elixir
([#128](#128))
([3adffb8](3adffb8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

4 participants