Module containers: a root singleton reaching a module service while a module singleton needs a root singleton deadlocks (lock order root/module inverted)
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #6545 by @rbuergi — merged
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with Doc/Architecture/ReadingASiloEviction and the lock ordering described here, then inspect ModuleOwnedRootSource, the Current transient forwarder, ModuleServiceProxy.Invoke, ModuleHealthCheckOptionsForwarder, and ModuleFallbackSource. Build a deterministic two-container regression test that forces both first-time singleton builds to overlap; it should fail before the fix and pass after the lock order is made consistent.
Written by the indexing model from the issue text.
Description
Found while fixing #6432 (PR #6536). Recorded in Doc/Architecture/ReadingASiloEviction under "What is still open, and not this incident".
The shape. Autofac holds a scope's shared-instance lock for the whole build of a shared instance, and that lock covers every shared instance in the scope.
- Thread A builds a ROOT singleton. It holds the root container's lock. The singleton's construction reaches a module's service, and that service is not built yet, so A waits for the module container's lock. A root singleton reaches a module through any of these paths:
ModuleOwnedRootSource, the stand-ins for module-declared types;- the
Currentroute's transient forwarder; ModuleServiceProxy.Invoke, for example anIConfigureOptions<T>a module contributed, invoked when a root singleton readsIOptions<T>.Valuein its constructor;ModuleHealthCheckOptionsForwarder, invoked fromDefaultHealthCheckService's constructor.
- Thread B builds a MODULE singleton. It holds that module container's lock. The singleton's construction needs a root singleton that is not built yet.
ModuleFallbackSourceresolves it in the module scope'sRootResolutionScope, and a root singleton is shared in the root, so B waits for the root lock.
The two locks are taken in opposite orders, which is the same deadlock as #6432. It was reproduced with real containers in a throwaway test while reading the #6432 dump. No production dump has shown it yet.
What has NOT been established: whether any running instance has hit it. It needs two first-time builds that overlap.
Wanted: fix it so the two locks are always taken in the same order, with a deterministic two-container regression test that forces the overlap: red before the fix, green after.
🤖 Generated with Claude Code
- Dominant language
- C#
- Stars
- 12
- Forks
- 5
- Avg merge
- 4h 50m
- Merged PRs (30d)
- 949
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Systemorph/MeshWeaver
-
bug control-image sev:M
Difficulty 4/5 3-5 days Newbie friendliness 15/100
Systemorph/MeshWeaver#6761 ·
Maintainers usually reply within 1 day
-
bug sev:M
Difficulty 4/5 3-5 days Newbie friendliness 18/100
Systemorph/MeshWeaver#6759 ·
Maintainers usually reply within 1 day
-
bug sev:M
Difficulty 3/5 1-2 days Newbie friendliness 40/100
Systemorph/MeshWeaver#6753 · 1 comment ·
Maintainers usually reply within 1 day
-
bug feature:unanchored-queries sev:M
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Systemorph/MeshWeaver#6752 · 1 comment ·
Maintainers usually reply within 1 day
-
bug feature:node-delete sev:M
Difficulty 4/5 3-5 days Newbie friendliness 15/100
Systemorph/MeshWeaver#6751 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Systemorph/MeshWeaver
Similar issues
-
documentation
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
-
bug misleading tooling trivial
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Docs example projects pinned to a literal library version instead of 3.*Possibly taken @DaveSkender claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
facioquo/stock-indicators-dotnet#2372 ·
Maintainers usually reply within 1 day
-
[Docs] officecli-docx SKILL.md still describes `\n` as a soft line break after #262Possibly taken @giprime claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Facepunch/sbox-public#12097 ·
Maintainers usually reply within 2 days