-
Notifications
You must be signed in to change notification settings - Fork 54
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
Prevent distributed singletons created during other's init from duping IDs #1132
Conversation
285538b
to
a9ed30f
Compare
…g IDs resolves apple#1131 rdar://112434926
a9ed30f
to
c1ded19
Compare
do { | ||
return try SWIMActor.resolve(id: ._swim(on: self.asClusterNode!), using: system) | ||
} catch { | ||
fatalError("Failed to resolve \(ActorID._swim(on: self.asClusterNode!).detailedDescription): \(error), tree: \n\(system._treeString())") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just improving error message, should not happen in real code but helps debug when we mess up assignID ;)
where Act: DistributedActor | ||
{ | ||
let props = _Props.forSpawn // task-local read for any properties this actor should have | ||
let props = _Props.forSpawn.consume() // task-local read for any properties this actor should have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fix™
Tests/DistributedClusterTests/Plugins/ClusterSingleton/ClusterSingletonPluginTests.swift
Outdated
Show resolved
Hide resolved
Just one of the jobs had a timeout #1133 failure |
Motivation:
We need to "consume" the sneaky way we sneak in the "use this ID" into
assignID
. Without this we'd assign the same ID if someone were to create a singleton DURING the init() of another singleton.I need to work around a few aggressive assertions that are trying to prevent users doing bad stuff that we actually do want to do here, but this'll work ok.
Modifications:
We "consume" the "props for spawn" during assignID as it should be. This works because that's code generated as first thing in every distributed actor init.
Result:
resolves #1131
rdar://112434926
relates to rdar://112433423 which is about a language feature to enable control over this properly.