Skip to content

Fix flaky TableClientTest.testTableAPIServerSideRouting#4802

Open
void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:fix-routing-proxy-inputstream
Open

Fix flaky TableClientTest.testTableAPIServerSideRouting#4802
void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:fix-routing-proxy-inputstream

Conversation

@void-ptr974
Copy link
Copy Markdown
Contributor

@void-ptr974 void-ptr974 commented May 27, 2026

Motivation

TableClientTest.testTableAPIServerSideRouting can fail intermittently with txnResult.isSuccess() returning false.

Observed failure:

Failed to intercept table request {rangeId=1030, routingKey=74786e2d6b6579, streamId=1026}
java.lang.IllegalArgumentException: Invalid unknonwn tag type: 4
    at org.apache.bookkeeper.stream.proto.kv.rpc.LightProtoCodec.skipUnknownField(...)
    at org.apache.bookkeeper.stream.proto.kv.rpc.TxnRequest.parseFrom(...)
    at org.apache.bookkeeper.stream.storage.impl.routing.RoutingHeaderProxyInterceptor.parseTxnRequest(...)

The server-side routing proxy forwards table requests as InputStreams. When the interceptor tries to rewrite the routing header, it reads the request stream first. If parsing or interception fails, the old fallback returned the same InputStream instance. At that point the stream has already been consumed, so the backend receives an empty or partially consumed request instead of the original request body. That can make the proxied txn fail and surfaces as the flaky integration test failure.

Changes

  • Buffer the original request bytes before attempting to parse and rewrite proxied table requests.
  • Reuse the buffered bytes when mutating the routing header for proxy-style InputStream requests.
  • On interception failure, rebuild a fresh request stream from the original bytes so fallback forwarding preserves the request body.
  • Add a regression test that sends invalid proxy request bytes through IdentityInputStreamMarshaller and verifies the delegate receives a fresh stream with the original payload.

Testing

  • mvn -pl stream/storage/impl -am -P '!mac,!cargo-zigbuild' -DstreamTests -Dtest=RoutingHeaderProxyInterceptorTest -Dsurefire.failIfNoSpecifiedTests=false test

@void-ptr974 void-ptr974 changed the title Fix routing proxy fallback for consumed request streams Fix flaky TableClientTest server-side routing failure May 27, 2026
@void-ptr974 void-ptr974 changed the title Fix flaky TableClientTest server-side routing failure Fix flaky TableClientTest.testTableAPIServerSideRouting May 27, 2026
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