Skip to content

v2.24.3

Choose a tag to compare

@bpacholek bpacholek released this 10 Oct 00:07
· 120 commits to main since this release

Patch release. An infinite JetStream pull consumer run (PullConsumerIterator::handle() without setIterations()) no longer drops messages it has received when the connection reconnects (#187). Before, the run threw its pulls in flight away at a reconnect together with what they held, and dropped every message none of its pulls had room for. The server counted those messages as delivered, so they came again only after ack_wait, or never on a consumer with ack_policy: none or max_deliver: 1.

Upgrading is recommended for every infinite pull consumer worker that runs with reconnect enabled, the default. There are no API changes.

Fixed

  • What the pulls received before a reconnect reaches the handler (#187). When the connection's reconnect count moves, the run ends its pulls in flight instead of dropping them: what they received goes to the handler first, in order, before it pulls again on the new connection. This covers a message the reconnect's own delivery gave a pull, and the answer to a pull issued on the new connection before the run noticed a reconnect that the handler's own ack() ran.
  • Messages the run's pulls had no room for are delivered, not dropped (#187). A server that outlived the connection (a dropped socket, a Stale Connection close) still serves the requests the run issued before the reconnect once the reconnect has subscribed the run's inbox again, and a pull written during the outage goes out from the reconnect buffer afterwards. What none of the run's pulls has room for is now held for the handler, in arrival order, behind what the pulls hold. Measured on nats-server 2.12.15 with the worker's socket closed while the server stayed up (batch 1, depth 1, ack_policy: none): after the reconnect the consumer held two waiting requests and the worker received m-1 and m-2. With 2.24.2 the handler got only m-1; with 2.24.3 it gets both.
  • A status the old connection brought no longer ends the run (#187). A 409 Consumer Deleted, or a stale-pin 423, that a pull got before the reconnect is ignored once the run has ended that pull, also when the reconnect happened in the handler of an earlier pull; it used to end the run through onError, or drop a pinned group's pin. The iterator's drain() across a reconnect now delivers what the pulls in flight had received.

Before upgrading

  • Across a reconnect, the handler can get more messages than setBatching() times setDepth() before the run pulls again, and the result of handle() counts them. The run issues no new pull while it holds such messages.
  • A terminal pull status (409 Consumer Deleted, say) now hands over what the pulls behind the one it ended hold before handle() resolves; those messages used to be left unacked.
  • stop(), disconnect() and a client drain() whose budget runs out still leave the rest undelivered. The iterator's drain(), the client's drain() within its budget and a run that fails hand it over, and the drain's drain deadline exceeded report counts it.
  • Finite runs (setIterations()) are unchanged: they keep their exact count and drop a message past their last pull's batch, as fetchBatch() does. symfony-nats-messenger fetches with fetchBatch() and is not affected.

Quality gates

  • PHPStan level 8.
  • 3172 unit tests (with data sets) on PHP 8.2 to 8.5, 151 live integration tests and 48 Behat scenarios.
  • Statement coverage 98.85% from the unit suite (95% floor enforced in CI) and 98.91% combined (97% floor).
  • Infection covered MSI 93.2% over the 3719 mutants it ran (90% floor enforced in CI); it skipped 4738 of the 8457 it generated as too slow, so the score does not include them.
  • 30 new unit cases, decided by the order of events: 29 fail on 2.24.2 and one is a guard for finite runs. A new live integration test fails on 2.24.2. Two existing mutation tests that pinned the old behaviour were retargeted, one of them because a terminal status now hands over the tail.
  • On the changed lines, CI's 20 s per-mutant budget skips 99 of 114 mutants as too slow and none escape. With a 240 s budget all 114 ran: 78 killed, 22 timed out, 11 errored and 3 escaped, all three equivalent; covered MSI 97%.
  • symfony-nats-messenger against this change: PHPStan level max and 528 unit tests pass.

The full record is in the CHANGELOG.