Skip to content

[fix][fn] Fix Go function runtime to continue after user exceptions and add neg-ack tests - #25867

Merged
lhotari merged 1 commit into
apache:masterfrom
Dream95:fix_go_function
May 25, 2026
Merged

[fix][fn] Fix Go function runtime to continue after user exceptions and add neg-ack tests#25867
lhotari merged 1 commit into
apache:masterfrom
Dream95:fix_go_function

Conversation

@Dream95

@Dream95 Dream95 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Motivation

Go function runtime currently exits the processing loop when user code returns an error, which causes behavior inconsistency with Java/Python runtimes and prevents expected retry/negative-ack flow in failure scenarios.
This PR aligns Go runtime behavior for user-function failures and adds integration coverage for Go neg-ack semantics.

This PR aligns Go runtime behavior for user-function failures and adds integration coverage for Go neg-ack semantics.

Modifications

  • In pulsar-function-go/pf/instance.go:
    • Refactored error handling into helper methods (handleUserError, handlePublishError).
    • Changed user-function error path from returning error (exit loop) to continuing message processing.
    • Added shouldNackInputOnFailure() and enabled nack for ATLEAST_ONCE and MANUAL on user-function failures.
    • Kept publish-error handling with system exception metrics and appropriate ack/nack behavior.
  • In pulsar-function-go/pf/instance_test.go:
    • Added Go exception function example: tests/docker-images/latest-version-image/go-examples/exceptionFunc/exceptionFunc.go.
    • Updated Docker image build to include the new Go example artifact.
    • Added testGoFunctionNegAck in Go integration test suite.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

./gradlew :tests:integration:integrationTest \
  -PintegrationTestSuiteFile=pulsar-process.xml \
  -PtestGroups=go_function

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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

If the box was checked, please highlight the changes

  • 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
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Matching PR in forked repository

PR in forked repository: Dream95#10

…nd add neg-ack tests

Signed-off-by: Dream95 <zhou_8621@163.com>

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lhotari lhotari added this to the 5.0.0-M1 milestone May 25, 2026
@lhotari
lhotari merged commit a5c1029 into apache:master May 25, 2026
45 of 46 checks passed
@Dream95
Dream95 deleted the fix_go_function branch May 26, 2026 06:43
lhotari pushed a commit that referenced this pull request Jun 1, 2026
…nd add neg-ack tests (#25867)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit a5c1029)
lhotari pushed a commit that referenced this pull request Jun 1, 2026
…nd add neg-ack tests (#25867)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit a5c1029)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 9, 2026
…nd add neg-ack tests (apache#25867)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit a5c1029)
(cherry picked from commit 6fb674d)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 28, 2026
…nd add neg-ack tests (apache#25867)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit a5c1029)
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.

2 participants