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

Change event prefix to preserve order under load #89

Merged
merged 2 commits into from
Jun 5, 2023
Merged

Conversation

fkorotkov
Copy link
Contributor

When there are a lot of events streamed from a worker, it's possible to have two batches coming for the same timestamp (which is a timestamp of the event on the worker). This way the existing logic would mess up the order because index and the random number doesn't guarantee the order.

To fix this I've changed the format of the prefix for the event to include tro things:

  1. Timestamp in nanoseconds of the injection time on the controller so two sequential batches will have guaranteed order unless they are processed within a nanosecond.
  2. Made the index being fixed length with trailing zeros, so they are properly lexicographically sorted (000001, 000002, ...).

Fixes #88

When there are a lot of events streamed from a worker, it's possible to have two batches coming for the same timestamp (which is a timestamp of the event on the worker). This way the existing logic would mess up the order because `index` and the random number doesn't guarantee the order.

To fix this I've changed the format of the prefix for the event to include tro things:

1. Timestamp in nanoseconds of the injection time on the controller so two sequential batches will have guaranteed order unless they are processed within a nanosecond.
2. Made the `index` being fixed length with trailing zeros, so they are properly lexicographically sorted (`000001`, `000002`, ...).
@fkorotkov fkorotkov requested a review from edigaryev June 5, 2023 15:00
@fkorotkov fkorotkov enabled auto-merge (squash) June 5, 2023 16:58
@fkorotkov fkorotkov merged commit f6b48b7 into main Jun 5, 2023
2 checks passed
@fkorotkov fkorotkov deleted the fixed-log-order branch June 5, 2023 17:01
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.

Order of logs lines sometimes is messed up
2 participants