fix(shard-distributor): send initial state to new subscribers#7499
Merged
jakobht merged 8 commits intocadence-workflow:masterfrom Dec 2, 2025
Merged
fix(shard-distributor): send initial state to new subscribers#7499jakobht merged 8 commits intocadence-workflow:masterfrom
jakobht merged 8 commits intocadence-workflow:masterfrom
Conversation
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
eleonoradgr
reviewed
Dec 1, 2025
|
|
||
| // The go routine sends the initial state to the subscriber. | ||
| go func() { | ||
| n.RLock() |
Contributor
There was a problem hiding this comment.
we are already locking and inside the function we can remove this
eleonoradgr
reviewed
Dec 1, 2025
| func (n *namespaceShardToExecutor) Subscribe(ctx context.Context) (<-chan map[*store.ShardOwner][]string, func()) { | ||
| return n.pubSub.subscribe(ctx) | ||
| subCh, unSub := n.pubSub.subscribe(ctx) | ||
| n.logger.Info("initial state", tag.ShardNamespace(n.namespace), tag.Value(n.getExecutorState())) |
Contributor
There was a problem hiding this comment.
I would suggest to move this in the go routine and use the same state that we are going to send instead of querying the method twice
Member
Author
There was a problem hiding this comment.
I think we don't need this log at all, deleted it
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
eleonoradgr
approved these changes
Dec 1, 2025
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed?
Modified the
Subscribemethod innamespaceShardToExecutorto send the initial executor state to new subscribers immediately upon subscription, and refactoredgetExecutorStateinto a separate method to safely retrieve a copy of the current state.Removed logic for sending initial state from the handler. The logic didn't send the metadata for the executors.
Improved test infrastructure by updating
setupExecutorWithShardsto use atomic etcd transactions and to properly delete old testdata.Why?
New subscribers were not receiving the initial state when they subscribed to the executor state pub/sub, causing them to wait for the next update before getting data. This lead to delays in subscribers getting the current shard distribution.
The test improvements ensure executor setup happens atomically and makes tests more maintainable by ensuring deletion of stale state.
How did you test it?
Unit tests
Potential risks
Release notes
Documentation Changes