From 4a5eb26f4ee3302a65e6433458fb196492a11564 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 01:20:35 +0100 Subject: [PATCH] views: read the durable's ack floor up to a mark, not its pending count, after the handlers spoke MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- go/views/process_reader_integration_test.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/go/views/process_reader_integration_test.go b/go/views/process_reader_integration_test.go index 8d2d7b1f..a044ecd0 100644 --- a/go/views/process_reader_integration_test.go +++ b/go/views/process_reader_integration_test.go @@ -154,7 +154,9 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) { hub := process.NewEventHub(t.Logf) 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.*"} { - 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) } } @@ -230,12 +232,25 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) { if len(got["a"])+len(got["b"])+len(seatHeard) != 0 { 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()) if err != nil { t.Fatal(err) } - if info, err := cons.Info(ctx); err != nil || info.NumAckPending != 0 { - t.Fatalf("a message was left unacknowledged: %+v %v", info, err) + if info, err := cons.Info(ctx); err != nil || info.AckFloor.Stream < mark.Sequence { + 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, // though the reader started twice. -- 2.54.0