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

Prevent distributed singletons created during other's init from duping IDs #1132

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

ktoso
Copy link
Member

@ktoso ktoso commented Jul 18, 2023

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.

@ktoso ktoso force-pushed the wip-dupe-id-singleton-during-init branch from 285538b to a9ed30f Compare July 18, 2023 16:02
@ktoso ktoso force-pushed the wip-dupe-id-singleton-during-init branch from a9ed30f to c1ded19 Compare July 18, 2023 16:02
@ktoso ktoso requested a review from yim-lee July 18, 2023 16:13
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())")
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix™

@ktoso
Copy link
Member Author

ktoso commented Jul 19, 2023

Just one of the jobs had a timeout #1133 failure

@ktoso ktoso merged commit e5effb9 into apple:main Jul 19, 2023
@ktoso ktoso deleted the wip-dupe-id-singleton-during-init branch July 19, 2023 04:02
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.

DA spawned by a ClusterSingleton inherits _Props and leads to duplicateActorPath error
2 participants