Change partition_by to return a random partition instead of a nil value for a parition_by function #298
+78
−5
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_key
beingnil
meant that sinceThen any events with a
nil
partition_key
would exhaust the available subscribers - draining them from other queues - and especially in our case where 99% of events were going to thenil
queue - meaning this queue always get priority vs other queues in terms of consuming events. This happened due to inEventStore.Subscriptions.SubscriptionFsm.next_available_subscriber/2
this never resolving into an existing queue:which meant that events for the
nil
queue would always grab a new Subscriber instead of grouping up with an existing one already processing anil
queue event. This exhausted the subscribers and prevented other queues with less events from being processed.This fix prevents the issue by replacing
nil
partition_keys with a random partition based on the max_size that will allow the event queues to be processed with equal priority whenpartition_by
isnil
or returnsnil
.This
nil
behavior was kept for whenpartition_by
isnil
since it optimizes the parallelism of the "default" behavior when nopartition_by
is provided.