Repository navigation
Conversation
Signed-off-by: 1fanwang <1fannnw@gmail.com>
|
Assigning reviewers: R: @kennknowles for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Reminder, please take a look at this pr: @kennknowles |
|
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @ahmedabu98 for label java. Available commands:
|
|
R: @sjvanrossum Since you made some of the surrounding comments, are you able to review this? |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
|
If I'm not mistaken, the default value of I recall that the Pub/Sub team was going to raise the maximum payload size from 10 MB to 10 MiB. If they did, then the unaccounted overhead above 2.5 MB should fit in the additional ~0.5 MB that you get out of 10 MiB. TL;DR The proposed change leaves 25% of the maximum accepted payload size unused and raising the default maximum accepted payload size may still lead to a rejection of the batch publish request. |
…tch-size-28011 Signed-off-by: 1fanwang <1fannnw@gmail.com>
|
OK so that sounds like something we shouldn't do. Is there a way to just make this all more precise byte tracking and less offline math? |
Each client reports the bytes a message adds to the publish request it sends: the JSON body for REST, the protobuf encoding for gRPC. The writer cuts batches against the 10 MB request limit with those sizes, and a message that cannot fit a request fails before anything is published. Fixes apache#28011 Signed-off-by: 1fanwang <1fannnw@gmail.com>
…tch-size-28011 Signed-off-by: 1fanwang <1fannnw@gmail.com> # Conflicts: # CHANGES.md
Yes. Each client now reports the exact bytes a message adds to the request it sends, the JSON body for REST and the protobuf for gRPC, and the writer cuts batches against the 10 MB limit with those sizes, so the batching does no offline sums. The per-message validator that runs first is unchanged. The PR description has a before and after run. |
…tch-size-28011 # Conflicts: # CHANGES.md
A bounded PubsubIO write can send a publish request that Pub/Sub rejects for being over its 10 MB limit (limits). The writer ends a batch by adding up the payload, attribute and ordering key sizes of its messages, and that sum is not the size of the request the client sends. In the reproducer below, 100 messages that each carry 100 maximum-size attributes go out as one 12.9 MB request, and attribute values made of control characters, which JSON writes as six-byte escapes, make it 64 MB.
Each client now reports what a message adds to the request it sends: the JSON body for REST, the protobuf encoding for gRPC. The writer starts a new request before the next message would pass 10 MB, and fails before publishing anything when a message cannot fit in a request at all. withMaxBatchBytesSize now bounds the encoded request, and 10 MB is its default, up from 7.5 MB.
Pub/Sub does not document whether its limit applies to the REST body or to the transcoded protobuf (#31800), so each client measures what it sends. The per-message validator that runs before the writer is unchanged.
Fixes #28011
Testing Done
The reproducer writes 100 messages, each with 100 maximum-size attributes, through a bounded PubsubIO write on the direct runner: once with plain attribute values and once with control-character values. A local HTTP server stands in for Pub/Sub. It reads each publish request that the real JSON client sends and answers 400 to any request over 10,000,000 bytes. Nothing talks to live Pub/Sub, and the gRPC client is not part of this run; PubsubGrpcClientTest compares its sizes with the serialized request.
Before: the main sources from base commit 0fa1aca.
After: the main sources from this branch.
Reproducer source: PubsubBatchRepro.java
Reproducer source: cp.init.gradle.kts
allprojects { afterEvaluate { if (path == ":sdks:java:io:google-cloud-platform") { val testRuntime = configurations.getByName("testRuntimeClasspath") val mainOutput = extensions.getByType<SourceSetContainer>()["main"].output tasks.register("printTestRuntimeClasspath") { dependsOn("classes") inputs.files(testRuntime) doLast { println(mainOutput.asPath + ":" + testRuntime.asPath) } } } } }