Skip to content

v2.24.4

Choose a tag to compare

@bpacholek bpacholek released this 10 Oct 04:55
· 117 commits to main since this release

Patch release. Requests now work while the client's drain() delivers. A pull consumer handler that acks with ackSync() therefore no longer processes every handed-over message twice (#213). The request that sets up the shared reply inbox also keeps to its own timeout now (#194).

Upgrading is recommended for every worker that drains its client on shutdown (SIGTERM) while a pull consumer or a subscription handler makes requests. There are no API changes.

Fixed

  • ackSync() and other requests during drain() (#213). Since 2.24.0 the client's drain() hands what a pull consumer run holds to its handler. The connection refused every request while Draining, so ackSync() failed there and the server delivered each message again after ack_wait. Measured on nats-server 2.12.15 with the iterator's defaults: 29 of 87 messages were processed twice in one shutdown.

    The drain now keeps the shared reply inbox subscribed until it has delivered everything. It also sets the inbox up for a worker that has made no request yet. Requests made during that phase go through the existing bounded request writers. This covers ackSync(), JetStream publish, Key/Value reads and writes, request() and requestMany(), from pull consumer handlers and from core subscription handlers.

    The drain stays within its single budget. When delivery ends, or at the drain's deadline, any request still waiting fails with Connection is not open. Whatever is still undelivered is counted in the drain deadline exceeded report before those requests are woken.

  • Reply-inbox setup within the request's own budget (#194). A request whose reply inbox SUB met a dead socket waited up to another requestTimeoutMs for the reconnect, and could be sent after its deadline. It now times out with its own Request timed out for subject <subject> while waiting for the reply inbox to be set up. Requests that joined that setup no longer fail with its timeout.

Before upgrading

  • This withdraws the 2.24.0 advice to ack with ack() in a handler that may run during a drain.
  • The drain's UNSUB of the reply inbox now comes after the requests on the wire.
  • A drain with a connection hands nothing over past its deadline, not even the first message of a new delivery pass. It used to hand one more message to a handler whose request-based ack would have been refused; the deadline report now counts that message instead. A drain that found no connection to drain keeps its final backlog pass.
  • disconnect() ends the requests in flight as it begins, rather than once the transport's close fails their reads. A request made while that close is under way is not sent.
  • A request from another fiber is taken while the drain delivers, but the drain does not wait for its reply. Give a JetStream publish made there a msgId.
  • subscribe() stays refused while Draining. So do the operations that need a subscription of their own:
    • fetchBatch() and fetchNext();
    • a pull consumer's new pulls;
    • batched Direct Get, Key/Value keys() and history();
    • multi-chunk Object Store downloads.

Quality gates

  • PHPStan level 8.
  • 3214 unit tests (with data sets) on PHP 8.2 to 8.5, 152 live integration tests and 48 Behat scenarios.
  • Statement coverage 98.83% from the unit suite (95% floor enforced in CI) and 98.89% combined (97% floor).
  • Infection covered MSI 93.28% over the 3675 mutants it ran (90% floor enforced in CI); it skipped 4906 of the 8581 it generated as too slow, so the score does not include them.
  • 40 new unit cases and one new live integration test. Every new regression test fails on 2.24.3, the live one included; the 8 declared guards pass on both. All 46 runnable examples pass; pull-consumer-graceful-drain.php now acks with ackSync() and fails on 2.24.3.
  • On the changed lines, CI's 20 s per-mutant budget skips most mutants as too slow. With a 120 s budget, 245 mutants: 69 killed, 19 escaped, 3 timed out, 154 still skipped. Of the 19, 11 are now killed by added tests, 6 went away when redundant code was simplified, and 2 are equivalent.

The full record is in the CHANGELOG.