carlos / platform Public

test: signal paused requests after they read the namespace claim

Astra final re-review 2, Minor: the two paused-request tests signalled
on the claims List, but the claim cache reads each body after it, so
the rollback or remove could retire the claim before the admitted
request read it. nsRollbackRaceStore and nsViewSignalStore now close
their channel when that listing's Get of the namespace key returns.
Test-only; both tests pass 20 of 20 with -count=20.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev dd16273a7dd74fe6664dde113defcc75a77ed934 parent d30d8ff
1 file changed, +40 −9
  • internal/console/subdomain_retire_test.go +40 −9

CI failed — run details

Intent

Attributed to this commit: 55.8 g CO₂e (7,314,956 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-account-name-hosts, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/subdomain_retire_test.go b/internal/console/subdomain_retire_test.go
index 86c47f1c5..08242cbdc 100644
--- a/internal/console/subdomain_retire_test.go
+++ b/internal/console/subdomain_retire_test.go
@@ -382,12 +382,18 @@ func TestSubdomainRollbackSparesASuccessor(t *testing.T) {
}
}
-// nsViewSignalStore signals the first claim listing after it is armed: the
-// moment a door has loaded its namespace view.
+// nsViewSignalStore signals once a door has loaded its namespace view: the
+// first claims listing after it is armed, and then that listing's read of
+// key, the namespace claim's body (the claim cache lists first and reads
+// each body after, claimcache.go listWithHosts). listed closes only once
+// that read has returned, so nothing the test does next can change the
+// body the door judges.
type nsViewSignalStore struct {
release.Store
+ key string
mu sync.Mutex
armed bool
+ inList bool
listed chan struct{}
}
@@ -395,13 +401,23 @@ func (s *nsViewSignalStore) List(ctx context.Context, prefix string) ([]string,
keys, err := s.Store.List(ctx, prefix)
s.mu.Lock()
if s.armed && prefix == domains.ClaimsPrefix {
- s.armed = false
- close(s.listed)
+ s.armed, s.inList = false, true
}
s.mu.Unlock()
return keys, err
}
+func (s *nsViewSignalStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ body, etag, err := s.Store.Get(ctx, key)
+ s.mu.Lock()
+ if s.inList && key == s.key {
+ s.inList = false
+ close(s.listed)
+ }
+ s.mu.Unlock()
+ return body, etag, err
+}
+
func (s *nsViewSignalStore) DeleteIfMatch(ctx context.Context, key, etag string) error {
return release.DeleteIfMatch(ctx, s.Store, key, etag)
}
@@ -423,7 +439,7 @@ func TestSubdomainRetiredInterleaving(t *testing.T) {
if code, _, out := sdReq(t, fx, http.MethodPost, fx.sqid, w.token, `{"name":"harbour"}`); code != http.StatusOK {
t.Fatalf("set harbour for bab = %d %s", code, out)
}
- store := &nsViewSignalStore{Store: fx.rel, armed: true, listed: make(chan struct{})}
+ store := &nsViewSignalStore{Store: fx.rel, key: domains.ClaimKey(nsHarbourHost), armed: true, listed: make(chan struct{})}
fx.srv.cfg.Releases = store
fx.srv.claims.Reset()
@@ -504,8 +520,12 @@ func TestSubdomainRetiredInterleaving(t *testing.T) {
// (Important 1) inside one set: right after set's Put of key it runs
// admit (another request is admitted under the name the Put exposed), and
// then fails the next record walk once, so set's re-read fails and it
-// rolls back. claimsListed closes on the first claims listing after
-// armClaims, the admitted request's namespace view.
+// rolls back. claimsListed closes once the admitted request has loaded its
+// namespace view: after the first claims listing following armClaims, on
+// the return of that listing's read of key, the namespace claim's body (the
+// claim cache lists first and reads each body after, claimcache.go
+// listWithHosts). So the rollback cannot retire the claim before the
+// admitted request has captured it active.
type nsRollbackRaceStore struct {
release.Store
key string
@@ -514,6 +534,7 @@ type nsRollbackRaceStore struct {
admitted bool
failWalk bool
armClaims bool
+ inList bool
claimsListed chan struct{}
}
@@ -547,13 +568,23 @@ func (s *nsRollbackRaceStore) List(ctx context.Context, prefix string) ([]string
keys, err := s.Store.List(ctx, prefix)
s.mu.Lock()
if s.armClaims && prefix == domains.ClaimsPrefix {
- s.armClaims = false
- close(s.claimsListed)
+ s.armClaims, s.inList = false, true
}
s.mu.Unlock()
return keys, err
}
+func (s *nsRollbackRaceStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ body, etag, err := s.Store.Get(ctx, key)
+ s.mu.Lock()
+ if s.inList && key == s.key {
+ s.inList = false
+ close(s.claimsListed)
+ }
+ s.mu.Unlock()
+ return body, etag, err
+}
+
func (s *nsRollbackRaceStore) DeleteIfMatch(ctx context.Context, key, etag string) error {
return release.DeleteIfMatch(ctx, s.Store, key, etag)
}