You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 79692a9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(daemon): read inherited lease records only after the registration is held
The releaser now touches no file in the state directory until the daemon
calls recoverInherited, after its registration is acquired: that step loads
the expired record, adopts the live journal and starts recovery. A daemon
refused the registration leaves the live journal byte-identical. A durable
expired record rewrites the journal, and ADR 0007 names both routes where the
registry forgets a provider lease without a crash.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy file name to clipboardExpand all lines: docs/adr/0007-remote-device-leases.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,11 +88,14 @@ Shutdown waits for any lease-end teardown that already started before it tears s
88
88
A daemon that dies while it holds a provider lease leaves the rented device running on the provider side, and that device stays billed.
89
89
Thus, the daemon journals the live leases of each provider that can recover an expired lease, in `live-provider-leases.json` in its state directory.
90
90
A daemon that starts and finds this journal hands each lease in it to the expired-lease recovery of its provider, which ends the rented device.
91
-
It does so only after it holds the daemon registration for the state directory, because until then the journal can belong to a daemon that is still running.
91
+
It reads both lease records only after it holds the daemon registration for the state directory, because until then they can belong to a daemon that is still running.
92
92
The lease itself is not restored, and its controller connects again.
93
93
Restoring the live lease was rejected: the sessions and device claims of the dead daemon are gone, so a restored lease would name a device that no session can reach.
94
94
A lease that leaves the registry for expiry stays in the journal until its expired-lease record is durable, and a journal write that fails is retried.
95
-
One gap remains: the registry releases a canceled first allocation without a provider release, so that lease leaves the journal while its provider start may still run, and a crash in that interval loses it.
95
+
Two routes still let the registry forget a provider lease while its device may be rented. The journal and expiry recovery both follow the registry, so neither covers it, and only the provider runtime still holding the device can end it:
96
+
97
+
- A failed first allocation releases the registry entry without a provider release, while its provider start may still run.
98
+
- An allocation that finishes after its requester left releases the registry entry even when the provider release throws.
96
99
97
100
When a request closes a session, the daemon ends the lease of that session, unless the lease was allocated with `retainOnClose`.
98
101
The reply to that request reports each lease that it ended once, at response level, as `endedLeases: [{ leaseId, outcome: 'released' }]`.
0 commit comments