Repository navigation
v2.25.2
Patch release. A pull consumer run that fails now closes its reply inbox before it hands what its pulls hold to your handler. The server stops serving the run's pulls, so a message published during that hand-over stays in the stream for the next pull instead of being dropped (#212).
Upgrading is recommended for pull consumers on ack_policy: none or max_deliver: 1 whose runs can fail: a read or write failure, handlerErrorsFailOperations, or a rejected inbox. There are no API changes; the new pieces are internal.
Fixed
-
A failing run releases its inbox before the hand-over (#212). Since 2.22.0 a run that fails hands its buffered messages to the handler first (#197). It released its inbox only in its
finally, after that hand-over. The server knew nothing of the failure, so for as long as the hand-over lasted it kept serving the run's pulls with whatever was published meanwhile. The run dropped those messages unacked: read after itsUNSUB, or as stragglers once no pull was open. A reconnect completed during the hand-over even subscribed the inbox again. Onack_policy: noneormax_deliver: 1such a message was lost; otherwise it came again afterack_wait.The run now closes its inbox first, through a new connection-owned operation,
NatsClient::retirePullInbox()(@internal):- Open connection:
UNSUBand aPINGgo out in one write. What the server sent before theUNSUBis read into the pulls until thePONG, within onerequestTimeoutMsbudget. - Client
drain()under way: the drain's ownUNSUBand flush stand in for that write. - Reconnecting or closed: the inbox only leaves the replay.
The release then seals the inbox so nothing more reaches the run. It never throws: a timeout or failure is reported to the error listener as a warning, never in place of the run's own failure, and a
stop()ends it at once.Measured on nats-server 2.12 with
ack_policy: none. A message published while the handler held the first of two buffered messages:- 2.25.1: the consumer showed
delivered 3, and the message was never handled. - 2.25.2: the message stays pending, and the next
fetchNext()gets it.
- Open connection:
Before upgrading
handle()of a failing run throws its failure up to one round trip later, at mostrequestTimeoutMs.- The handler no longer gets messages the server delivers during the hand-over: they stay in the stream for the next pull.
- An error listener may now get a
TimeoutExceptionwarning ("Releasing the pull consumer inbox ...") when the server does not answer the release'sPINGin time.
Quality gates
- PHPStan level 8.
- 3334 unit tests (with data sets) on PHP 8.2 to 8.5, 155 live integration tests and 49 Behat scenarios. All runnable examples pass.
codecov/patch100%: every changed line is covered. Total coverage 99.02%, unchanged.- Infection covered MSI 92.96% (90% floor enforced in CI) on the final source. It skipped 5064 of the 8744 mutants it generated as too slow, so the score does not include them. Of the mutants that survived on the first push in the new code, the ones not equivalent are now killed by tests.
- New cases:
PullConsumerFailedRunInboxReleaseTest: 13 cases, all of which fail on 2.25.1.RetirePullInboxTest: 17 cases, covering each state and each early end of the release.- A live integration test, run with
ack_policy noneand with explicit acks atmax_deliver 1. On 2.25.1 it showsdelivered 3and the lost message.
The full record is in the CHANGELOG.