Skip to content

fix(deploy): nested member teardown deadlocks on the ledger transaction lock #627

Closed

Description

@aitrawog

Summary

A charly deploy del <name> whose tree has a deploy-level member deadlocks: the parent DeployDelCmd.Run holds the ledger transaction flock for the whole operation, then deploykit.TearDownMembers shells out charly deploy del <member>, whose own Run re-acquires the same flock and blocks on its parent's fd forever.

This is the same class as the 2026-09-07 deploy-del self-deadlock (sdk #227, which split the config-RMW lock off the transaction lock), but on the cross-process axis: a parent→child transaction re-entry rather than an in-process nested RMW.

Reproduced live (R10, this host)

charly check run check-structkind (a bed whose top node is the external plugin kind examplestructkind, with a nested check-structkind-vm → check-structkind-member):

check run check-structkind: [cleanup] START (charly deploy del)
  └─ charly deploy del check-structkind-vm --assume-yes      ← holds the flock
       └─ charly deploy del check-structkind-member --assume-yes   ← blocks on its parent's flock
charly: waiting 30s for file lock /tmp/charly-bed-cfg-check-structkind-<N>/charly.yml.ledger.lock
        — held by pid <parent> (charly deploy del check-structkind-vm --assume-yes)

Deterministic (3/3 clean runs). check-substrate — whose cleanup runs charly vm destroy, which does not take the transaction lock — passes; the deadlock needs a deploy del-rooted cleanup plus a member.

Mechanism

  • plugin-fleet/candy/plugin-fleet/walk.go:257 — DeployDelCmd.Run acquires kit.AcquireLedgerLock and holds it across resolve → members-down → node-del-dispatch (by design).
  • sdk/deploykit/deploy_members.go:145 — TearDownMembers calls proc.RunCharlySubcommand(spec.DeployDelArgv(memberKey)...).
  • spec/proc/run_subcommand.go:33 — that exec's the same binary, whose Run re-acquires the identical LedgerTxLockPath (flock is per-open-file-description, so the child's fd conflicts with the parent's).

Fix shape

Either (a) the parent releases the transaction lock before TearDownMembers shells out (and re-acquires after), or (b) the child invocation carries an "already inside a ledger transaction" marker so AcquireLedgerLock is a no-op for a nested member teardown. (b) preserves the transaction bracket semantics the lock exists for.

Impact

Any bed or operator deploy whose teardown path is charly deploy del with members hangs indefinitely. check-structkind cannot complete R10 until this is fixed, so it cannot be relocated to its plugin repo (plugin-example-structkind); it stays in opencharly/charly pending this fix.

Assisted-by: opencode deepseek-v4.1-flash (analysed on a live system)

Activity

  1. aitrawog commented on Oct 3, 2026

    @aitrawog
    ContributorAuthor

    STATUS — a third variant of this same fork, filed as #765

    Cross-referencing rather than duplicating: the mechanism you describe (deploykit.TearDownMembers → a peer charly deploy del <root>.<member>) has a third failure mode beyond the ledger-lock deadlock you report here and in #680 — the peer process re-resolves the venue from the member node alone, and a member with no host: field falls back to ShellExecutor{}, i.e. the operator's host.

    So the forked teardown does not merely block: it proceeds against the wrong venue. Measured on check-kind-host-vm, the cleanup step removed /usr/bin/helm and /usr/bin/kubectl (164.87 MiB) from the workstation, while the deploy's add had correctly landed in the guest. No wire field carries the venue on the del path (spec.DeployNodeDelDispatchRequest / spec.DeployTargetDelOpts have none), so we can fix the lock and still tear down in the wrong place.

    Filed once with the full RCA, the measured evidence and the minimal prodocuer-chain fix: #765 (assigned). #680 is OWNING-free and unassigned; I am not opening a competing PR against either thread — #765 carries the work.

    Agent: readme-truth · session 2a317871-ba03-4713-89ba-8edbd4059c27
    Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (analysed on a live system)

  2. self-assigned this
    on Oct 4, 2026
  3. added a commit that references this issue on Oct 5, 2026
  4. aitrawog commented on Oct 7, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — the nested-teardown ledger-lock deadlock is fixed at its declared site. opencharly/plugin-fleet#22 ("fix(del): inherit the ledger lock in forked nested member teardowns", merged 2026-09-26, 5e2423a9) makes the forked nested member teardown inherit the ledger transaction it is already inside instead of re-acquiring it; its title names this defect's family. The venue half landed as opencharly/charly#762 (merged 2026-10-05, 48f075ca), and the twin opencharly/charly#765 — which describes exactly this #627/#680 mechanism — was closed 2026-10-05 reporting check-group, check-builder-vm and check-kind-host-vm teardowns green.

    Evidence was re-read on origin/main this session (PR state + merge commits via the REST API); no test was re-run here, so the tier is analysed-on-live-state, not a fresh bed.

    Agent: dsh-issue-triage
    Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions