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

Recreate ordered pull on heartbeats #1178

Merged
merged 5 commits into from
Jan 19, 2024
Merged

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Dec 22, 2023

This PR adds few improvements to ordered consumers:

  • It will recreate ordered pull consumers if heartbeats are missed twice
  • It will retry all push and pull ordered consumer recreation API calls to have chance of success in case of network/consensus instasbilities
  • Add more tracing

Above provide smoother experience for working with ordered consumers in unstable network/consensus/extreme load conditions.

This PR also replaces tokio_retry with (tryhard)[https://github.com/EmbarkStudios/tryhard], ask I found bug in how tokio_retry counts backoffs. Also tryhard is actively maintained by a well know entity.

Signed-off-by: Tomasz Pietrek [email protected]

@Jarema Jarema force-pushed the recreate-ordered-pull-on-heartbeats branch from dda151f to dc5fec4 Compare December 22, 2023 09:00
Copy link
Contributor

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

Some comments around exponential backoff

async-nats/src/jetstream/consumer/pull.rs Show resolved Hide resolved
@Jarema Jarema force-pushed the recreate-ordered-pull-on-heartbeats branch 3 times, most recently from 09b2442 to 87ad89b Compare January 18, 2024 13:40
After running extensive chaos testing, we found that there is
possible to improve client code resilience for ordered consumer
ability to self heal and recreate itself.
The main change is adding retires for all operations related to
recreating the consumer.
This PR also improved tracing.
No tests were added, as those are long running ones and now well suited
to library tests. They will become part of chaos testing.

Signed-off-by: Tomasz Pietrek <[email protected]>
We found out that tokio_retry does not compute exponential backoff
properly. This commit switches to a better supported crate maintained by a well
known org.

Signed-off-by: Tomasz Pietrek <[email protected]>
@Jarema Jarema force-pushed the recreate-ordered-pull-on-heartbeats branch from 87ad89b to 1c234e9 Compare January 18, 2024 13:42
Signed-off-by: Tomasz Pietrek <[email protected]>
Copy link
Contributor

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

LGTM!

@Jarema Jarema merged commit af0a135 into main Jan 19, 2024
11 checks passed
@Jarema Jarema deleted the recreate-ordered-pull-on-heartbeats branch January 19, 2024 11:17
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.

2 participants