From 4df9c4b03b0e9c104c53b442d31c8ef5d2835b67 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 03:11:09 +0100 Subject: [PATCH] N2 remove-never-delivered: the held-pull row judges a durable never delivered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 H ยง837 1., H-A-852, H-A-860, H-A-868 (1984/AC-837b) --- modules/nats/cmd/nats-tools/removal_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/nats/cmd/nats-tools/removal_test.go b/modules/nats/cmd/nats-tools/removal_test.go index 9b5024972..1a424f600 100644 --- a/modules/nats/cmd/nats-tools/removal_test.go +++ b/modules/nats/cmd/nats-tools/removal_test.go @@ -245,14 +245,16 @@ accounts { MESH { jetstream: enabled, users: [ if _, err := ajs.Publish(ctx, "mesh.events.one", []byte("{}")); err != nil { t.Fatal(err) } - // Made after the message, from the stream's end, as the grants part makes them (H-A-868): the stream sequence is - // 2 before their start, the consumer's own count of deliveries 0. ace_q is never delivered; ace_held too, and a - // pull is held open on it. - for _, d := range []string{"ace_q", "ace_held"} { + // Made after a message, from the stream's end, as the grants part makes them (H-A-868): the stream sequence reads the + // stream's position before their start (1 for ace_q, 2 for ace_held), the consumer's own count of deliveries 0. + // ace_q is never delivered, no pull on it. ace_held is made below, after the second message, so its held fetch + // delivers nothing. + fromEnd := func(d string) { if _, err := ajs.CreateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: d, AckPolicy: jetstream.AckExplicitPolicy, DeliverPolicy: jetstream.DeliverNewPolicy}); err != nil { t.Fatal(err) } } + fromEnd("ace_q") for _, d := range []string{"novox_m", "novox_m_tools", "ace_q_tools", "ace_solo", "g14_both", "g14_both_tools"} { if _, err := ajs.CreateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: d, AckPolicy: jetstream.AckExplicitPolicy}); err != nil { t.Fatal(err) @@ -261,6 +263,7 @@ accounts { MESH { jetstream: enabled, users: [ if _, err := ajs.Publish(ctx, "mesh.events.one", []byte("{}")); err != nil { t.Fatal(err) } + fromEnd("ace_held") for _, d := range []string{"novox_m", "novox_m_tools", "ace_q_tools", "ace_solo", "g14_both", "g14_both_tools"} { c, _ := ajs.Consumer(ctx, "EVENTS", d) if _, err := c.Next(jetstream.FetchMaxWait(2 * time.Second)); err != nil { @@ -289,6 +292,12 @@ accounts { MESH { jetstream: enabled, users: [ } } } + if ci, err := func() (*jetstream.ConsumerInfo, error) { + c, _ := ajs.Consumer(ctx, "EVENTS", "ace_held") + return c.Info(ctx) + }(); err != nil || ci.Delivered.Consumer != 0 || ci.NumWaiting != 1 { + t.Fatalf("ace_held must be never delivered with one pull held: %+v %v", ci, err) + } handActs = nil for _, tl := range removalTools(adminBus, say, nil, accepted, func(q meshhandactsclient.Request) error { handActs = append(handActs, q); return nil }, nil, nil) { if tl.Name == "nats_consumer_remove" { @@ -298,7 +307,7 @@ accounts { MESH { jetstream: enabled, users: [ for _, row := range []struct{ consumer, refused string }{ {"novox_m_tools", "it is no orphan: 1 pulls waiting on it"}, {"ace_q_tools", "its twin ace_q on EVENTS is not current"}, - {"ace_held", "it is no orphan: 1 pulls waiting on it"}, // never delivered, a pull held: the pull check comes first (1984/AC-837b) + {"ace_held", "it is no orphan: 1 pulls waiting on it"}, // consumer sequence 0 (asserted above), a pull held: the pull check comes before the never-delivered rule (1984/AC-837b) {"ace_solo", "a module of an accepted manifest"}, {"g14_both", "it is no orphan: 1 pulls waiting on it"}, {"g14_both_tools", "it is no orphan: 1 pulls waiting on it"},