Skip to content

v2.25.3

Choose a tag to compare

@bpacholek bpacholek released this 10 Oct 18:49
· 93 commits to main since this release

Patch release. An infinite pull consumer run that ends on a terminal status, such as 409 Consumer Deleted after a consumer is deleted and recreated under the same name, now hands your handler what its later pulls received after that status, instead of dropping it (#211).

Upgrading is recommended for infinite pull consumers on ack_policy: none or max_deliver: 1 whose consumers can be deleted and recreated while they run. There are no API changes; the new pieces are internal.

Fixed

  • A terminal status no longer drops what came after it (#211). The case: a consumer is deleted and recreated while the handler works on a batch.

    1. The waiting pull's 409 Consumer Deleted sits unread on the socket.
    2. When the handler returns, the run refills, and the refill reaches the recreated consumer, which serves it at once.
    3. The engine then reads the 409 and ends the run.

    Since 2.24.3 the run hands over what the pulls behind the status hold (#187). That covered the refill's messages only when they came in the same read as the 409. When they came a read later, which is the likelier timing, they were read after the run's UNSUB and dropped.

    Before it reports the status to onError, the run now closes its inbox with the release a failing run uses since 2.25.2 (NatsClient::retirePullInbox(), #212):

    • UNSUB and PING go out in one write.
    • What the server sent before the UNSUB is read into the pulls or the overflow until the PONG, within one requestTimeoutMs budget. This happens even with nothing behind the status.
    • onError then gets the status once, and the tail is handed over and counted.

    The inbox's rejection observer is kept until the run's final unsubscribe. So a permissions violation read by onError or during the hand-over still ends the run with the rejection (#206).

    Measured on nats-server 2.12, with the worker reading one protocol frame at a time:

    • 2.25.2: the handler got m-1 only.
    • 2.25.3: the handler gets m-1 and m-2, and handle() returns 2.

Before upgrading

  • onError for a terminal status, and handle()'s result, come up to one round trip later, at most requestTimeoutMs.
  • An error listener may get a TimeoutException warning ("Releasing the pull consumer inbox ...") when the server does not answer the release's PING in time.
  • A stop() during that round trip returns the count without calling onError. A rejection of the inbox recorded meanwhile ends the run with the rejection, and the client's drain() asking for the hand-over ends it with the hand-over; onError is not called in either case.
  • Finite runs, 423 pin recovery and the routine statuses (404, 408, 503, non-terminal 409) are unchanged.

Quality gates

  • PHPStan level 8.
  • 3348 unit tests (with data sets) on PHP 8.2 to 8.5, 157 live integration tests and 49 Behat scenarios. All runnable examples pass.
  • codecov/patch 100%: every changed line is covered. Total coverage 99.03%.
  • Infection covered MSI 92.95% (90% floor enforced in CI). It skipped 5083 of the 8771 mutants it generated as too slow, so the score does not include them. The two mutants that survived in the new code (continue 2 → continue 1 / break at the drain/rejection checkpoint) are equivalent: either way the run reaches the loop top without issuing a pull.
  • New cases:
    • PullConsumerTerminalStatusInboxReleaseTest: 13 cases. 12 fail on 2.25.2, plus one declared guard.
    • A RetirePullInboxTest case for the retained rejection observer.
    • A live delete/recreate integration test, run with ack_policy none and with explicit acks at max_deliver 1. It passes 5/5 and fails 3/3 on 2.25.2.
  • The three #206 tests the issue names are unchanged, and they fail without the new retirement record.

The full record is in the CHANGELOG.