Change partition_by to return a random partition instead of a nil value for a parition_by function #298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue we were facing where the
partition_keybeingnilmeant that sinceThen any events with a
nilpartition_keywould exhaust the available subscribers - draining them from other queues - and especially in our case where 99% of events were going to thenilqueue - meaning this queue always get priority vs other queues in terms of consuming events. This happened due to inEventStore.Subscriptions.SubscriptionFsm.next_available_subscriber/2this never resolving into an existing queue:which meant that events for the
nilqueue would always grab a new Subscriber instead of grouping up with an existing one already processing anilqueue event. This exhausted the subscribers and prevented other queues with less events from being processed.This fix prevents the issue by replacing
nilpartition_keys with a random partition based on the max_size that will allow the event queues to be processed with equal priority whenpartition_byisnilor returnsnil.This
nilbehavior was kept for whenpartition_byisnilsince it optimizes the parallelism of the "default" behavior when nopartition_byis provided.