Two writers, one config repo: the community-app poll and the space-ID door clobber each other — the wallet's space IDs 502 after the credential verified #1747

Closed
opened 2026-09-22 19:22:13 +00:00 by ben · 2 comments
Owner

What happens

On a community whose app was chosen AT FOUNDING, the first steward's wallet cannot record the community's any-sync space IDs. The door verifies the credential and then 502s:

{"code":"spaces_unavailable","message":"the community's space IDs could not be recorded — try again shortly"}

Cause: two writers, one git repo, no lock

The control plane's community-app POLL and the space-ID door both write the config repo at /srv/idss/config through internal/clan's git helpers. They are not serialised, so they clobber each other. From the box, seconds apart:

19:19:48 WARN community-app poll: could not record the status … err="clan: git add -A: context canceled: "
19:19:50 WARN … err="clan: provision config repo at /srv/idss/config: clan: git config --local maintenance.auto …"
19:19:51 WARN … err="clan: provision config repo at /srv/idss/config: clan: git config --local gc.auto 0: exit status …"   (×3 in 300 ms)
19:20:03 INFO community space-ID door: steward credential verified   aid=EFJt6…  credential=EAk_K…
          → the door then failed its own write and answered 502

The poll also retries hard while it is failing (three attempts in ~300 ms), which widens the window rather than backing off.

Why it has not bitten before: on the "later" route the wallet records the spaces BEFORE Design your community app is ever pressed, so the poll is not running yet. Choosing the app at founding starts the poll during founding, so from then on every config-repo write shares the gateway with it.

Evidence

Debug IDIP fire 20260922T185624Z (elitebook-03, a5acd1c6, app-at-founding), leg wallet-records-spaces — the only red (40/41 green). artifacts/wallet-records-spaces.json carries the challenge (200, the door's own address) and the 502. The credential was verified — this is the STORE failing, not a refusal.

Acceptance

  • One writer at a time on the gateway's config repo: every writer (the community-app poll, the space-ID door, the descriptor writer, the identity recorder) goes through one lock, and a writer that cannot take it waits rather than failing the caller.
  • The space-ID door does not answer 502 because another writer held the repo; a genuine store failure still says so.
  • The poll backs off instead of retrying three times in 300 ms.
  • Seam test: two concurrent writers, both writes land, neither caller sees an error.
  • The IDIP journey's app-at-founding variant (rehearsal-target: idip-app-founding) goes green through wallet-records-spaces.
  • GOTCHAS entry.

Blocks #1522's prove-it on its own route. Found by the founding-route drive (map #1293).

## What happens On a community whose app was chosen AT FOUNDING, the first steward's wallet cannot record the community's any-sync space IDs. The door verifies the credential and then **502**s: ``` {"code":"spaces_unavailable","message":"the community's space IDs could not be recorded — try again shortly"} ``` ## Cause: two writers, one git repo, no lock The control plane's community-app POLL and the space-ID door both write the config repo at `/srv/idss/config` through `internal/clan`'s git helpers. They are not serialised, so they clobber each other. From the box, seconds apart: ``` 19:19:48 WARN community-app poll: could not record the status … err="clan: git add -A: context canceled: " 19:19:50 WARN … err="clan: provision config repo at /srv/idss/config: clan: git config --local maintenance.auto …" 19:19:51 WARN … err="clan: provision config repo at /srv/idss/config: clan: git config --local gc.auto 0: exit status …" (×3 in 300 ms) 19:20:03 INFO community space-ID door: steward credential verified aid=EFJt6… credential=EAk_K… → the door then failed its own write and answered 502 ``` The poll also retries hard while it is failing (three attempts in ~300 ms), which widens the window rather than backing off. Why it has not bitten before: on the "later" route the wallet records the spaces BEFORE *Design your community app* is ever pressed, so the poll is not running yet. Choosing the app at founding starts the poll during founding, so from then on every config-repo write shares the gateway with it. ## Evidence Debug IDIP fire `20260922T185624Z` (elitebook-03, `a5acd1c6`, app-at-founding), leg `wallet-records-spaces` — the only red (40/41 green). `artifacts/wallet-records-spaces.json` carries the challenge (200, the door's own address) and the 502. The credential was verified — this is the STORE failing, not a refusal. ## Acceptance - [ ] One writer at a time on the gateway's config repo: every writer (the community-app poll, the space-ID door, the descriptor writer, the identity recorder) goes through one lock, and a writer that cannot take it waits rather than failing the caller. - [ ] The space-ID door does not answer 502 because another writer held the repo; a genuine store failure still says so. - [ ] The poll backs off instead of retrying three times in 300 ms. - [ ] Seam test: two concurrent writers, both writes land, neither caller sees an error. - [ ] The IDIP journey's app-at-founding variant (`rehearsal-target: idip-app-founding`) goes green through `wallet-records-spaces`. - [ ] GOTCHAS entry. Blocks #1522's prove-it on its own route. Found by the founding-route drive (map #1293).

swarm-claim host=matou-dev-server-01 run=30359
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=30359 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1747 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1747,
  "status": "success",
  "commits": [
    "d47412a691b81e135406c6d1eb6b4612eafa2b8b"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/configrepo.go",
    "internal/clan/configrepo_concurrent_test.go",
    "internal/communityapp/poll.go",
    "internal/communityapp/poll_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/clan/ ./internal/communityapp/ -count=1",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/ -run TestConfigRepo_TwoConcurrentWriters -race -count=1",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/controlapi/ ./internal/founding/ ./internal/orgconfig/ ./internal/spaces/ -count=1",
      "exit_code": 0
    },
    {
      "command": "go build ./control-plane/... ./internal/...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/clan/ ./internal/communityapp/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "One writer at a time on the gateway's config repo: every writer goes through one lock, and a writer that cannot take it waits rather than failing the caller": "The community-app poll, space-ID door, descriptor writer and identity recorder already share ONE *clan.ConfigRepo (main.go:215) and serialise on its single-writer mutex; the fix makes that lock effective by running each mutation's git under a context DECOUPLED from the caller's (context.WithoutCancel + configRepoMutationTimeout) so a waiting writer finds a clean repo instead of one a cancelled predecessor poisoned — internal/clan/configrepo.go Mutate/ResetToRevision.",
    "The space-ID door does not answer 502 because another writer held the repo; a genuine store failure still says so": "The door's Save (r.Context()) now completes atomically once it holds the lock — a returned request no longer SIGKILLs git mid-write nor leaves a stale lock that failed the door; a genuine store error still returns and the door still answers 502 spaces_unavailable (internal/controlapi/spaces.go:379 unchanged). Proven by TestConfigRepo_CancelledCallerContextStillLands + TestConfigRepo_StaleLockIsSweptAndTheWriteLands.",
    "The poll backs off instead of retrying three times in 300 ms": "internal/communityapp/poll.go: Refresh coalesces a burst of on-open refreshes into one poll (claimPollSlot within refreshGap) and pollOnce returns not-reached on a write failure so Run doubles its ticker delay. Proven by TestPoller_RefreshBurstCoalescesToOnePoll.",
    "Seam test: two concurrent writers, both writes land, neither caller sees an error": "internal/clan/configrepo_concurrent_test.go TestConfigRepo_TwoConcurrentWriters_BothLand_NoCallerError (also run under -race).",
    "The IDIP journey's app-at-founding variant (rehearsal-target: idip-app-founding) goes green through wallet-records-spaces": "Fixed the product defect that 502'd wallet-records-spaces; the live app-at-founding fire is a drive I cannot run in the sandbox — it rides the next fire (recorded in STATUS.md and the commit's Owed line), as prior IDIP fixes in this arc have.",
    "GOTCHAS entry": "docs/GOTCHAS.md #313 — a config-repo writer under the caller's request context left a stale .git/*.lock that 502'd the next writer; Symptom/Cause/Rule."
  },
  "summary": "A config-repo mutation now completes under a caller-decoupled context and sweeps stale git locks, so a returned request no longer leaves a lock that 502s the space-ID door; the poll coalesces refresh bursts and backs off on write failure.",
  "reason": "",
  "blockers": []
}
**close-report** for #1747 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1747, "status": "success", "commits": [ "d47412a691b81e135406c6d1eb6b4612eafa2b8b" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/configrepo.go", "internal/clan/configrepo_concurrent_test.go", "internal/communityapp/poll.go", "internal/communityapp/poll_test.go" ], "tests": [ { "command": "go test ./internal/clan/ ./internal/communityapp/ -count=1", "exit_code": 0 }, { "command": "go test ./internal/clan/ -run TestConfigRepo_TwoConcurrentWriters -race -count=1", "exit_code": 0 }, { "command": "go test ./internal/controlapi/ ./internal/founding/ ./internal/orgconfig/ ./internal/spaces/ -count=1", "exit_code": 0 }, { "command": "go build ./control-plane/... ./internal/...", "exit_code": 0 }, { "command": "go vet ./internal/clan/ ./internal/communityapp/", "exit_code": 0 } ], "criteria": { "One writer at a time on the gateway's config repo: every writer goes through one lock, and a writer that cannot take it waits rather than failing the caller": "The community-app poll, space-ID door, descriptor writer and identity recorder already share ONE *clan.ConfigRepo (main.go:215) and serialise on its single-writer mutex; the fix makes that lock effective by running each mutation's git under a context DECOUPLED from the caller's (context.WithoutCancel + configRepoMutationTimeout) so a waiting writer finds a clean repo instead of one a cancelled predecessor poisoned — internal/clan/configrepo.go Mutate/ResetToRevision.", "The space-ID door does not answer 502 because another writer held the repo; a genuine store failure still says so": "The door's Save (r.Context()) now completes atomically once it holds the lock — a returned request no longer SIGKILLs git mid-write nor leaves a stale lock that failed the door; a genuine store error still returns and the door still answers 502 spaces_unavailable (internal/controlapi/spaces.go:379 unchanged). Proven by TestConfigRepo_CancelledCallerContextStillLands + TestConfigRepo_StaleLockIsSweptAndTheWriteLands.", "The poll backs off instead of retrying three times in 300 ms": "internal/communityapp/poll.go: Refresh coalesces a burst of on-open refreshes into one poll (claimPollSlot within refreshGap) and pollOnce returns not-reached on a write failure so Run doubles its ticker delay. Proven by TestPoller_RefreshBurstCoalescesToOnePoll.", "Seam test: two concurrent writers, both writes land, neither caller sees an error": "internal/clan/configrepo_concurrent_test.go TestConfigRepo_TwoConcurrentWriters_BothLand_NoCallerError (also run under -race).", "The IDIP journey's app-at-founding variant (rehearsal-target: idip-app-founding) goes green through wallet-records-spaces": "Fixed the product defect that 502'd wallet-records-spaces; the live app-at-founding fire is a drive I cannot run in the sandbox — it rides the next fire (recorded in STATUS.md and the commit's Owed line), as prior IDIP fixes in this arc have.", "GOTCHAS entry": "docs/GOTCHAS.md #313 — a config-repo writer under the caller's request context left a stale .git/*.lock that 502'd the next writer; Symptom/Cause/Rule." }, "summary": "A config-repo mutation now completes under a caller-decoupled context and sweeps stale git locks, so a returned request no longer leaves a lock that 502s the space-ID door; the poll coalesces refresh bursts and backs off on write failure.", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1747
No description provided.