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

Keep assignments got from shard manager in updateAssignments #135

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

pancho-bo
Copy link
Contributor

It seems that here client will throw away assignments got from shard manager if there are any assignments already. Not sure if that was intended.

@ghostdogpr
Copy link
Collaborator

The assignments from Shard Manager contain the full map of assignments, so we can simply replace it.

@pancho-bo
Copy link
Contributor Author

The assignments from Shard Manager contain the full map of assignments, so we can simply replace it.

Does it mean that previous shardAssigments could be discarded altogether?

@ghostdogpr
Copy link
Collaborator

Does it mean that previous shardAssigments could be discarded altogether?

Yeah, I think I added the if (map.isEmpty) assignments else map as a defensive measure in case of weird behavior such as maybe calling the shard manager while it's loading or in a weird state. Basically an empty map is unexpected so we don't do anything in this case.

@pancho-bo
Copy link
Contributor Author

You probably mean that a non-empty map is unexpected, as sharding-client will refresh assignments during startup. And the first thing it will receive should be shard-manager response with its current state.
But there is another call to updateAssignments from the shard-manager, in the handle PodUnavailable error case. Calling updateAssignments at that time will have a non-empty current assignments and will ignore shard-manager response. That means that error will persist for some more time. Correct me if my understanding is wrong. I will try to come up with test case.

@ghostdogpr
Copy link
Collaborator

shardManager.getAssignments calls the shard manager directly, so it should be 100% reliable if it returns a response, as opposed to storage.getAssignments/storage.assignmentsStream which might be outdated/empty/miss something because it relies on Redis. That's why when a pod is unavailable, we try to get the latest state from the Shard Manager in case there was a storage issue. That value will be correct so it's okay to replace whatever we had before.

@pancho-bo
Copy link
Contributor Author

shardManager.getAssignments calls the shard manager directly, so it should be 100% reliable if it returns a response, as opposed to storage.getAssignments/storage.assignmentsStream which might be outdated/empty/miss something because it relies on Redis. That's why when a pod is unavailable, we try to get the latest state from the Shard Manager in case there was a storage issue. That value will be correct so it's okay to replace whatever we had before.

Agree. What I am trying to convey is that the code if (map.isEmpty) assignments else map is seeming to do exactly opposite, as it will keep the current, probably corrupted, map and discard received from shard manager, correct, assignments.

@ghostdogpr
Copy link
Collaborator

Ah, you are right, it's doing the opposite 🤔
I think maybe initially we were trying to set it only once, but now that we are calling it in handleError it doesn't make sense anymore.

@ghostdogpr ghostdogpr merged commit 9f1eb4a into devsisters:series/2.x Jul 22, 2024
5 checks passed
@ghostdogpr
Copy link
Collaborator

Thanks for the catch!

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