Skip to content

[fix][fn] Honour negativeAckRedeliveryDelayMs in the Go function runtime - #26415

Merged
nodece merged 1 commit into
apache:masterfrom
david-streamlio:fix-go-fn-nack-delay
Aug 24, 2026
Merged

[fix][fn] Honour negativeAckRedeliveryDelayMs in the Go function runtime#26415
nodece merged 1 commit into
apache:masterfrom
david-streamlio:fix-go-fn-nack-delay

Conversation

@david-streamlio

Copy link
Copy Markdown
Contributor

Fixes #26409
Master Issue: #26404

Motivation

SourceSpec.negativeAckRedeliveryDelayMs sets how long the broker waits before redelivering a negatively acknowledged message. The Go runtime negatively acknowledges on failure (instance.go:389-397, shouldNackInputOnFailure) but never configured the delay — NackRedeliveryDelay was absent from every ConsumerOptions it builds, so the client default of one minute always applied.

A function configured for fast retry, or for a long back-off from a struggling downstream, silently got neither. The Java runtime applies it; the Python runtime has the same gap, with a fix open at #26413.

Modifications

Add resolveNackRedeliveryDelay and set NackRedeliveryDelay on all four ConsumerOptions in setupConsumer — the regex and non-regex branches of both the receiver-queue-size path and the default path.

The field is a proto3 scalar with no presence, so an unset value reads as 0. Only a positive value produces a duration; zero leaves ConsumerOptions at its zero value, which the client treats as unset. That matches the guard JavaInstanceRunnable applies (if (sourceSpec.getNegativeAckRedeliveryDelayMs() > 0)) and means a function that does not configure the delay is unaffected.

Note this touches the same function as #26414 (retainOrdering / retainKeyOrdering), which is filed against a sibling issue under the same master issue. The two are independent — different fields, different lines — but whichever merges second will need a trivial rebase.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Four table-driven cases in pf/nackDelay_test.go: unset leaving the client default; milliseconds converted to a duration; a sub-second value preserved; and the client default expressed explicitly still round-tripping.
  • Confirmed the tests are not vacuous: making resolveNackRedeliveryDelay return 0 unconditionally fails the suite.
  • go build ./... and the full go test ./pf/ pass; go vet reports the same three pre-existing lock-copy warnings as master and no new ones.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • Anything that affects deployment

A Go function already deployed with --negative-ack-redelivery-delay gets the configured delay on its next restart instead of the 60s default. That is the option taking effect for the first time, but it is a behaviour change for anyone who set it and adapted to it being ignored. A function that does not set it is unaffected.

Documentation

  • doc-required
  • doc-not-needed
  • doc
  • doc-complete

The option is already documented; this makes the Go runtime honour it.

The Go runtime negatively acknowledges on failure but never configured
the redelivery delay, so the client default of 60 seconds applied
regardless of what SourceSpec.NegativeAckRedeliveryDelayMs carried.

Add resolveNackRedeliveryDelay and set NackRedeliveryDelay on all four
ConsumerOptions in setupConsumer - the regex and non-regex branches of
both the receiver-queue-size and default paths.

The field is a proto3 scalar with no presence, so an unset value reads as
0. Only a positive value produces a duration; zero leaves ConsumerOptions
at its zero value, which the client treats as unset. That matches the
guard the Java runtime applies in JavaInstanceRunnable, and means a
function that does not configure the delay is unaffected.

Fixes apache#26409
Master Issue: apache#26404

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nodece
nodece merged commit 12b86b1 into apache:master Aug 24, 2026
45 checks passed
@lhotari lhotari added this to the 5.0.0-M2 milestone Aug 24, 2026
david-streamlio added a commit to david-streamlio/pulsar that referenced this pull request Aug 24, 2026
Resolves a conflict in pulsar-function-go/pf/instance.go with apache#26415
(negativeAckRedeliveryDelayMs), which landed on master and added
resolveNackRedeliveryDelay at the same insertion point ahead of
setupConsumer.

Both helpers are kept. setupConsumer now resolves the subscription type
through resolveSubscriptionType and the redelivery delay through
resolveNackRedeliveryDelay, and all four Subscribe call sites carry both.
david-streamlio added a commit to david-streamlio/pulsar that referenced this pull request Aug 24, 2026
Resolves a conflict in pulsar-function-go/pf/instance.go with apache#26415
(negativeAckRedeliveryDelayMs), which landed on master and added
resolveNackRedeliveryDelay at the same insertion point ahead of
setupConsumer.

Both helpers are kept. setupConsumer now resolves the subscription type
through resolveSubscriptionType and the redelivery delay through
resolveNackRedeliveryDelay, and all four Subscribe call sites carry both.
Technoboy- added a commit that referenced this pull request Aug 26, 2026
…ime (#26415)

(cherry picked from commit 12b86b1)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Technoboy- pushed a commit that referenced this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go Functions] negativeAckRedeliveryDelayMs is ignored, so the client default always applies

4 participants