You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "capistrant (via GitHub)" <gi...@apache.org> on 2026/08/05 21:24:47 UTC
[PR] feat: Only do multipart uploads in `RetryableS3OutputStream` if the bytes to push expand beyond the threshold to do so (druid)
capistrant opened a new pull request, #19893:
URL: https://github.com/apache/druid/pull/19893
### Description
`RetryableS3OutputStream` was using multi-part upload scaffolding regardless of the bytes pushed for an individual upload. Now we will ensure we are going to be pushing more than 100MiB before we take the overhead of multipart uploads. In instances of small uploads that don't need multipart, you reduce API calls for that upload.
#### Release note
Improve s3 API usage efficiency for MSQ tasks using durable storage and msq export by only using multipart uploads when the bytes uploaded is larger than the multipart threshold.
<hr>
##### Key changed/added classes in this PR
* `RetryableS3OutputStream`
<hr>
<!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
This PR has:
- [ ] been self-reviewed.
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Only do multipart uploads in `RetryableS3OutputStream` if the bytes to push expand beyond the threshold to do so (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #19893:
URL: https://github.com/apache/druid/pull/19893#discussion_r3724324364
##########
extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/output/RetryableS3OutputStreamTest.java:
##########
@@ -217,11 +219,71 @@
s3.assertCancelled();
}
+ /**
+ * A multipart upload costs three S3 requests at minimum — create, upload part, complete — so a stream small enough
+ * to need only one part should not use one. A task writes one object per output partition, and every request lands
+ * on the same key prefix, so the per-object floor sets the burst rate against that prefix.
+ */
+ @Test
+ public void testStreamFittingInOneChunkIsUploadedWithASinglePut() throws IOException
+ {
+ chunkSize = 10;
+ ByteBuffer bb = ByteBuffer.allocate(Integer.BYTES);
+ try (RetryableS3OutputStream out =
+ new RetryableS3OutputStream(config, s3, path, s3UploadManager)) {
+ bb.putInt(1);
+ out.write(bb.array());
+ }
+
+ Assertions.assertEquals(0, s3.createMultipartUploadCount);
+ Assertions.assertEquals(0, s3.partRequests.size());
+ Assertions.assertNull(s3.completeRequest);
+ Assertions.assertEquals(ImmutableList.of((long) Integer.BYTES), s3.putObjectContentLengths);
+ }
+
+ /**
+ * Once a stream outgrows a single chunk it must use multipart, costing one create, one request per part, and one
+ * complete.
+ */
+ @Test
+ public void testStreamSpanningMultipleChunksUsesMultipartUpload() throws IOException
+ {
+ chunkSize = 10;
+ ByteBuffer bb = ByteBuffer.allocate(Integer.BYTES);
+ try (RetryableS3OutputStream out =
+ new RetryableS3OutputStream(config, s3, path, s3UploadManager)) {
+ for (int i = 0; i < 25; i++) {
+ bb.clear();
+ bb.putInt(i);
+ out.write(bb.array());
+ }
+ }
+
+ Assertions.assertEquals(1, s3.createMultipartUploadCount);
+ Assertions.assertEquals(10, s3.partRequests.size());
+ Assertions.assertEquals(0, s3.putObjectContentLengths.size());
+ s3.assertCompleted(chunkSize, Integer.BYTES * 25);
Review Comment:
## CodeQL / Result of multiplication cast to wider type
Potential overflow in [int multiplication](1) before it is converted to long by use in an invocation context.
[Show more details](https://github.com/apache/druid/security/code-scanning/11634)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Only do multipart uploads in `RetryableS3OutputStream` if the bytes to push expand beyond the threshold to do so (druid)
Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm merged PR #19893:
URL: https://github.com/apache/druid/pull/19893
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org