Skip to content

[fix][proxy] Return partition metadata responses for failed backend metadata requests - #26607

Open
void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:fix-proxy-partition-metadata-error-response
Open

void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:fix-proxy-partition-metadata-error-response

Conversation

@void-ptr974

Copy link
Copy Markdown
Contributor

Motivation

When a backend partition metadata request fails, the proxy returns a LOOKUP_RESPONSE instead of a PARTITIONED_METADATA_RESPONSE. Successful metadata requests and backend connection failures already use the partition metadata response. Returning the wrong command type makes the failure path inconsistent with the request and can cause differences for clients, protocol validation, and monitoring that distinguish the response types.

The Java client can still recognize the error because its lookup and partition metadata response handlers share the pending request map, which masks the protocol mismatch.

Modifications

  • Return Commands.newPartitionMetadataResponse for failed backend partition metadata requests, preserving the client request ID, error code mapping, and error message.
  • Add deterministic tests for authorization errors, wrapped topic-not-found errors, too-many-requests errors, and errors without a message, covering both already-failed and subsequently-failed futures.
  • Verify the serialized response type and payload, request IDs, error fields, frame size, single-response behavior, and connection release. Also cover successful partition counts and backend connection failure.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and was verified locally with:

./gradlew :pulsar-proxy:test \
  --tests 'org.apache.pulsar.proxy.server.LookupProxyHandlerTest' \
  --tests 'org.apache.pulsar.proxy.server.ProxyTest.testGetPartitionedMetadataErrorCode' \
  -PtestRetryCount=0 quickCheck

The 11 new unit test cases and the existing end-to-end Java client/Proxy/Broker test pass. quickCheck passes. Before the fix, the regression test failed because the serialized command type was LOOKUP_RESPONSE rather than PARTITIONED_METADATA_RESPONSE.

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

The binary protocol change corrects the response command type for failed backend partition metadata requests using the existing partition metadata response schema.

  • 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

…etadata requests

Use the partition metadata error response when a backend metadata request
fails, preserving the client request ID, error code, and error message.

Add protocol regression tests for metadata errors, successful responses,
and connection failures, including immediate and delayed failures.

Assisted-by: OpenAI Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant