console remote instances: the canary retire no longer restores a deleted pointer
Codex census review of 0719d069: the store treats an absent object as deleted, so no restore can prove it is putting back the revision this request removed; a concurrent removal could be resurrected. The restore path is gone. The retire compares record stamps just before the delete, re-reads the pointer, and deletes it conditionally on the etag its check read; a record written in the instant after that comparison reaches its box only after the serial bump, by which time the pointer is gone (the accepted residual for channels nobody has promoted). Record-write: handleRetireCanary has no write site any more.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+25
−73
docs/superpowers/notes/console-remote-instances.md+10 −9internal/console/remoteinstances_round4_test.go+0 −25internal/console/server.go+12 −33internal/provision/console_remote_instances_census_test.go+2 −5internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv+1 −1
CI passed — run details
diff --git a/docs/superpowers/notes/console-remote-instances.md b/docs/superpowers/notes/console-remote-instances.md| index 088cc5f7b..0f0fe3bf7 100644 |
| --- a/docs/superpowers/notes/console-remote-instances.md |
| +++ b/docs/superpowers/notes/console-remote-instances.md |
| @@ -316,15 +316,16 @@ conservative rule. |
| listing refuses any record key the follower read did not see. There is |
| no lock that record writes take (the app-mutation runner is a claim-mode |
| admission, not a lock), so the retire door takes the app's record keys |
| - and modification times before its check, again just before deleting the |
| - pointer, and once more right after. The delete is conditional on the |
| - pointer the check read, re-read just before (a promotion or removal |
| - meanwhile refuses, so no older bytes are ever restored), and a change seen |
| - after it puts those very bytes back, create-only, on a context the |
| - request's cancellation cannot end; a restore that fails is reported as a |
| - failure, not as a refusal. A |
| - record written after that last listing meets a channel with no pointer, |
| - which is no different from creating one on a channel nobody promoted. |
| + and modification times before its check and again just before deleting |
| + the pointer, and refuses on any difference. The delete is conditional on |
| + the pointer the check read, re-read just before, so a promotion or a |
| + removal meanwhile refuses. A record written in the instant between that |
| + last comparison and the delete reaches its box only after the serial |
| + bump, by which time the pointer is gone: no different from creating an |
| + instance on a channel nobody promoted, which the create door allows. No |
| + restore is attempted after the delete: the store cannot tell "deleted the |
| + revision read" from "already gone", so putting bytes back could |
| + resurrect a pointer someone else removed. |
| 3. **Identity for every route kind.** The rollout report covers only the |
| routes the rollout manages (never statics, non-hibernating instances or |
| unit-backed routes). Each box's edges file publishes the account and app |
diff --git a/internal/console/remoteinstances_round4_test.go b/internal/console/remoteinstances_round4_test.go| index 445b8efd2..2b158de05 100644 |
| --- a/internal/console/remoteinstances_round4_test.go |
| +++ b/internal/console/remoteinstances_round4_test.go |
| @@ -240,30 +240,6 @@ func TestRemoteInstancesListIgnoresSuccessorSample(t *testing.T) { |
| } |
| } |
| -// Codex census review of 55706243: a follower created after the last |
| -// comparison, as the pointer is deleted, puts the pointer back and refuses. |
| -func TestRetireRestoresPointerOnRecordCreatedDuringDelete(t *testing.T) { |
| - tb := newTwoBoxes(t) |
| - shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc") |
| - tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "stable") |
| - tb.reconcile(t, "v3") |
| - report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) |
| - ageRecords(t, tb) |
| - tb.fx.srv.boxReports.expire() |
| - before, _, err := tb.fx.rel.Get(context.Background(), release.ChannelKey(tb.sqid, "shop", "canary/rc")) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - tb.fx.srv.retireAfterDeleteHook = followerRecord(t, tb, "late.shop.example.com") |
| - if page := retireRC(t, tb); !strings.Contains(page, notSettled) { |
| - t.Fatalf("retire with a follower created during the delete:\n%s", page) |
| - } |
| - after, _, err := tb.fx.rel.Get(context.Background(), release.ChannelKey(tb.sqid, "shop", "canary/rc")) |
| - if err != nil || string(after) != string(before) { |
| - t.Fatalf("the pointer was not put back as it was: %v", err) |
| - } |
| -} |
| - |
| // Codex census review of 55706243: where the rollout report and the edges |
| // file disagree about a host no record names, the host has no identity to |
| // join, but either source naming this app still holds a retire. |
| @@ -431,7 +407,6 @@ func TestRetireDoesNotResurrectRemovedPointer(t *testing.T) { |
| t.Error(err) |
| } |
| } |
| - tb.fx.srv.retireAfterDeleteHook = followerRecord(t, tb, "late.shop.example.com") |
| if page := retireRC(t, tb); !strings.Contains(page, notSettled) { |
| t.Fatalf("retire with the pointer removed during the check:\n%s", page) |
| } |
diff --git a/internal/console/server.go b/internal/console/server.go| index 7fd849566..7762c2731 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -1196,9 +1196,6 @@ type Server struct { |
| // retireBeforeDeleteHook, when set, runs in the canary retire between |
| // the follower check and the final record comparison. Tests only. |
| retireBeforeDeleteHook func() |
| - // retireAfterDeleteHook, when set, runs right after the pointer's |
| - // delete, before the last record comparison. Tests only. |
| - retireAfterDeleteHook func() |
| // startedAt overrides when this console started (zero: the process |
| // start, processStart; tests set it), and deletions is when it last |
| // began deleting an instance or sidecar record of each app (acct + "/" |
| @@ -5499,7 +5496,7 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) { |
| ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second) |
| defer cancel() |
| key := release.ChannelKey(acct.Sqid, app, channel) |
| - pointer, pointerETag, err := s.cfg.Releases.Get(ctx, key) |
| + _, pointerETag, err := s.cfg.Releases.Get(ctx, key) |
| if errors.Is(err, os.ErrNotExist) { |
| back("err", "No canary named "+name+" here.") |
| return |
| @@ -5522,10 +5519,8 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) { |
| if !maps.Equal(before, after) { |
| return fmt.Errorf("%w: the app's records changed during the check", errRetireUnsettled) |
| } |
| - // The pointer must still be the one read above. DeleteIfMatch below |
| - // treats an absent object as deleted, so absence is checked here: a |
| - // pointer someone else promoted and removed meanwhile must not be |
| - // "restored" from this request's older bytes. |
| + // The pointer must still be the one read above: a promotion or a |
| + // removal meanwhile refuses. |
| if _, cur, gerr := s.cfg.Releases.Get(ctx, key); gerr != nil || cur != pointerETag { |
| if gerr != nil && !errors.Is(gerr, os.ErrNotExist) { |
| return gerr |
| @@ -5534,37 +5529,21 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) { |
| } |
| // Delete exactly the pointer read above: a promotion since then |
| // conflicts, and the retire is refused rather than deleting bytes |
| - // this check never saw (and restoring older ones below). |
| + // this check never saw. |
| if err := release.DeleteIfMatch(ctx, s.cfg.Releases, key, pointerETag); err != nil { |
| if errors.Is(err, release.ErrCASConflict) { |
| return fmt.Errorf("%w: the canary's pointer changed during the check", errRetireUnsettled) |
| } |
| return err |
| } |
| - if h := s.retireAfterDeleteHook; h != nil { |
| - h() |
| - } |
| - // No lock covers record writes, so a follower can still land between |
| - // that comparison and the delete. Compare once more after it: on any |
| - // change, put the pointer back (the very bytes deleted, create-only) |
| - // and refuse. This runs on its own context, so a request cancelled |
| - // after the delete cannot leave the pointer gone. A record written |
| - // after this listing meets a channel with no pointer, which is no |
| - // different from creating one on a channel nobody has promoted yet. |
| - rctx, rcancel := context.WithTimeout(context.WithoutCancel(ctx), 15*time.Second) |
| - defer rcancel() |
| - final, ferr := s.recordStamps(rctx, acct.Sqid, app) |
| - if ferr == nil && maps.Equal(before, final) { |
| - return nil |
| - } |
| - if _, perr := s.cfg.Releases.Put(rctx, key, pointer, ""); perr != nil { |
| - log.Printf("console: retire %s %s: RESTORING THE POINTER FAILED after a concurrent record change: %v", app, channel, perr) |
| - return fmt.Errorf("the app's records changed while retiring, and putting the pointer back failed (%v); promote the canary again", perr) |
| - } |
| - if ferr != nil { |
| - return fmt.Errorf("could not re-check the app's records after retiring, so the pointer was put back: %w", ferr) |
| - } |
| - return fmt.Errorf("%w: the app's records changed while retiring; the pointer was put back", errRetireUnsettled) |
| + // A record written after the comparison above and before this delete |
| + // reaches its box only after the serial bump, by which time the |
| + // pointer is gone: the same as creating an instance on a channel |
| + // nobody has promoted, which the create door allows. No restore is |
| + // attempted: the store cannot tell "deleted the revision read" from |
| + // "already gone", so putting bytes back could resurrect a pointer |
| + // someone else removed. |
| + return nil |
| }) |
| if errors.Is(err, errRetireUnsettled) { |
| log.Printf("console: retire %s %s: %v", app, channel, err) |
diff --git a/internal/provision/console_remote_instances_census_test.go b/internal/provision/console_remote_instances_census_test.go| index 582153074..33d952a8d 100644 |
| --- a/internal/provision/console_remote_instances_census_test.go |
| +++ b/internal/provision/console_remote_instances_census_test.go |
| @@ -34,10 +34,8 @@ package provision |
| // follower read did not see; Server.pageRecords reads the bucket, not |
| // the record view, for an app the console just deleted a record of. |
| // None writes anything: key-site. |
| -// - Server.handleRetireCanary gains one Put: after deleting the canary's |
| -// channel pointer, if the app's records changed meanwhile, it puts the |
| -// pointer back (its own signed bytes, read a moment before, create-only) |
| -// and refuses. A channel pointer, never a record: nonrecord. |
| +// - Server.handleRetireCanary's pointer delete is conditional on the etag |
| +// its check read; it writes no record and no other object. |
| // - Server.pageRecords is new (round 1 review): the app pages' record |
| // reader. It lists RecordsPrefix for the viewed account's app and reads |
| // each record not already a local row with GetRecord, through the |
| @@ -53,7 +51,6 @@ func consoleRemoteInstancesWriteCensusInventory() []censusEntry { |
| {"internal/console/claim_retire.go", "Server.retireClaimHostRecord", "key-site", "key:claimRetireRecordKey", "3c30cfcad8f2edb3c38b7dd9e56697cd3e17ce3a7fa0e76eb815adf3dad7bd4d"}, |
| {"internal/console/remoteinstances.go", "Server.retireUnsettled", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "f8060eaf63710c2326b3bcb10b545b15f21d91c52d540b0245d0dc5b83548ab6"}, |
| {"internal/console/remoteinstances.go", "Server.pageRecords", "key-site", "key:RecordsPrefix", "5298e5713404c168fdc4cfdc9995f57a5d3d61893d4b6c17f985877de59f8896"}, |
| - {"internal/console/server.go", "Server.handleRetireCanary", "nonrecord", "sel:Put", "9cfb06e3245d41e7583df0e3a03520ced2bd79b271b9b3c5a4078001f7c102dd"}, |
| {"internal/console/remoteinstances.go", "Server.recordStamps", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "c38f120e5be0e8c883b6da7d86df23a5b6b495a31732732e6cbe6efe5821ff43"}, |
| } |
| for _, r := range replacements { |
diff --git a/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv b/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv| index 6e08e5319..b7606de68 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv |
| @@ -21,5 +21,5 @@ internal/console/server.go Server.channelHosts legacy accepted-legacy accepted-l |
| internal/console/templates/app_overview.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Running tile does not claim Served when a route's state is unknown and reads the existing 'no data right now' when every instance's state is unknown; Web addresses tile reads 'no data right now' instead of 'DNS & certs OK' for a domain with no reading; display only. file:external@0 2a112ff768c300894881b858e61465841c87810ca7cb1d98a0fe2a54155a0ca1 |
| internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from a box report (rollout entry or edges-file owner) naming the record's own account and app and generated after the record existed (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's observation. Builds registry.Route literals from the record; reads no registry for them. registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@2893,whole:Route@3920,whole:Route@4519,whole:Route@4572,whole:Route@4687,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 791a8e223123dd5361e927bf69023edda74f5f347a4a63a83c00d9b3d55872c8 |
| internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and tenant-named box reports when given a remote source. registry:App@1716,registry:App@1739,registry:App@2117,registry:App@2147,registry:Backing@2017,registry:Caps@1385,registry:Channel@960,registry:Environment@1942,registry:Hibernate@1859,registry:Host@1768,registry:Host@861,registry:Kind@1783,registry:Platform@1889,registry:Provisioned@2042,registry:Status@1800,registry:Unit@1999,registry:Version@1823,whole:Route@2092,whole:Route@2167,whole:Route@810,whole:Route@839,whole:Route@910 120ae8c042523f872fd1c19357b8bb830e4afe9da1e38ad202df2ada3ad52ada |
| -@coverage internal/console cb41971c4ea35e636130328b6d3ad1783687f997bd8985a4e48069839d1d9b11 |
| +@coverage internal/console 3215df94bc068619202cff7b7bb14fb5d957f2f3fd41a138d82157c96a4e0b27 |
| @coverage internal/console/templates 6e272e30e00be5785b3f364a947ea4ab86b2d96a0e8d21821b7812c45f0a636f |