carlos / platform Public

fix: guard pool withdrawal deletes against forward rows

Add the required SQL kind guard and cover DeleteWithdrawnRoute in the route-writer inventory with ordinary and forward-row cases.
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev 79a18a156495d03be4e74fd95569bd6af45ef453 parent 3e3928a
2 files changed, +9 −1
  • internal/registry/forward_writers_test.go +8 −0
  • internal/registry/poolwithdrawal.go +1 −1
diff --git a/internal/registry/forward_writers_test.go b/internal/registry/forward_writers_test.go
index 689cc4cb1..49c68ace8 100644
--- a/internal/registry/forward_writers_test.go
+++ b/internal/registry/forward_writers_test.go
@@ -319,6 +319,13 @@ func replicaWriterCase(name string) writerCase {
func routeWriterCases() []writerCase {
ctx := context.Background()
cases := []writerCase{
+ {name: "DeleteWithdrawnRoute", encloses: []string{"DeleteWithdrawnRoute"},
+ setup: func(t *testing.T, r *Registry) (string, writerCall) {
+ rt := Route{Host: "withdraw.example.com", Account: "bbw", App: "shop", Kind: "instance", Status: "ready", Provisioned: true, Hibernate: true, Pool: "old", Region: "ie", Incarnation: 1}
+ mustUpsert(t, r, rt)
+ expected := mustRoute(t, r, rt.Host)
+ return rt.Host, func(bool) (bool, error) { return r.DeleteWithdrawnRoute(ctx, expected) }
+ }},
demoClaimSeedWriterCase("CompareSeedGate"),
demoClaimSeedWriterCase("DeleteSeedRoute"),
replicaWriterCase("SetReplicaAssignment"),
@@ -574,6 +581,7 @@ func routeWriterCases() []writerCase {
// boolWriters are the cases whose writer answers with a bool: the positive
// arm must see true.
var boolWriters = map[string]bool{
+ "DeleteWithdrawnRoute": true,
"DeleteSeedRoute": true,
"DeleteReplicaAssignment": true, "ReplaceReplicaAssignment": true,
"InstallLifetimeIf": true, "SetHoldIf": true, "SetHoldIfSeq": true, "HandHold": true, "ReleaseHold": true,
diff --git a/internal/registry/poolwithdrawal.go b/internal/registry/poolwithdrawal.go
index 05296ebe7..9d9c9354a 100644
--- a/internal/registry/poolwithdrawal.go
+++ b/internal/registry/poolwithdrawal.go
@@ -41,7 +41,7 @@ func (r *Registry) DeleteWithdrawnRoute(ctx context.Context, expected Route) (bo
if err != nil || protected {
return false, err
}
- if _, err = tx.ExecContext(ctx, `DELETE FROM routes WHERE host=?`, expected.Host); err != nil {
+ if _, err = tx.ExecContext(ctx, `DELETE FROM routes WHERE host=? AND kind <> 'forward'`, expected.Host); err != nil {
return false, err
}
if err = tx.Commit(); err != nil {