views: read the durable's ack floor up to a mark, not its pending count, after the handlers spoke

The views test read NumAckPending as soon as the picture and the adopted handler had said the last event, but the
reader acknowledges after both, and the bus takes acks on its own; on the loaded build node (pipeline main.54) one
ack was still pending. The reader binds the module's durable once (the hub's one pull); the guard of H-A-196 is not
involved. The test now publishes a mark the hub hands after every event before it, acknowledged with the bus's
answer, and reads that the ack floor reached the mark; an event the owner says after it may still wait.

Builds: design 47 H §774, H-A-196, H-A-197
This commit is contained in:
2026-11-21 01:20:35 +01:00
parent 173a8c120d
commit 4a5eb26f4e
+18 -3
View File
@@ -154,7 +154,9 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
hub := process.NewEventHub(t.Logf) hub := process.NewEventHub(t.Logf)
got := map[string]chan string{"a": make(chan string, 8), "b": make(chan string, 8)} got := map[string]chan string{"a": make(chan string, 8), "b": make(chan string, 8)}
for name, pattern := range map[string]string{"a": "mesh.mod.p.event.a", "b": "mesh.mod.q.event.b.*"} { for name, pattern := range map[string]string{"a": "mesh.mod.p.event.a", "b": "mesh.mod.q.event.b.*"} {
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.Ack(); got[name] <- m.Subject() }); err != nil { // The handlers' acknowledgement waits for the bus's answer, so a message a handler handed on is acknowledged
// on the bus, and every one the hub handed before it too (acks of one consumer are taken in order).
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.DoubleAck(ctx); got[name] <- m.Subject() }); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
@@ -230,12 +232,25 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
if len(got["a"])+len(got["b"])+len(seatHeard) != 0 { if len(got["a"])+len(got["b"])+len(seatHeard) != 0 {
t.Fatal("a handler heard a message that was another's, or one twice") t.Fatal("a handler heard a message that was another's, or one twice")
} }
// The reader acknowledges an event after it took it into its picture and the adopted handler returned, so the
// picture and the handler say nothing of its ack: one more event, handed after them in order and acknowledged with
// the bus's answer, is the mark that every ack before it has landed (the build node, main.54, read one pending). An
// event said after the mark (the owner's own mark of its burst) may still wait for its ack, so the floor is read.
mark, err := js.Publish(ctx, "mesh.mod.p.event.a", []byte(`"the mark"`))
if err != nil {
t.Fatal(err)
}
select {
case <-got["a"]:
case <-time.After(10 * time.Second):
t.Fatal("the mark after the handled events was not heard")
}
cons, err := js.Consumer(ctx, process.EventsStream, cred.EventConsumerName()) cons, err := js.Consumer(ctx, process.EventsStream, cred.EventConsumerName())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if info, err := cons.Info(ctx); err != nil || info.NumAckPending != 0 { if info, err := cons.Info(ctx); err != nil || info.AckFloor.Stream < mark.Sequence {
t.Fatalf("a message was left unacknowledged: %+v %v", info, err) t.Fatalf("a message up to the mark %d was left unacknowledged: %+v %v", mark.Sequence, info, err)
} }
// H-A-169: the one event no handler takes is the module's finding event-unhandled, counted once, naming its subject, // H-A-169: the one event no handler takes is the module's finding event-unhandled, counted once, naming its subject,
// though the reader started twice. // though the reader started twice.