Chunker: Always seek on the uncompressed stream.#15669
Chunker: Always seek on the uncompressed stream.#15669benjaminp wants to merge 1 commit intobazelbuild:masterfrom
Conversation
The `WriteRequest.write_offset` field has bizarre semantics during compressed uploads as documented in the remote API protos: https://github.com/bazelbuild/remote-apis/blob/3b4b6402103539d66fcdd1a4d945f660742665ca/build/bazel/remote/execution/v2/remote_execution.proto#L241-L248 In particular, the write offset of the first `WriteRequest` refers to the offset in the uncompressed source. This change ensures we always seek the uncompressed stream to the correct offset when starting an upload call. The old code could fail to resume compressed uploads under some conditions. The `progressiveCompressedUploadShouldWork` test purported to exercise this situation. The test, however, contained the same logic error as the code under test.
|
Would this fully fix #14654 then? Might be worth an inclusion in a 5.3 if one gets made. |
|
@bazel-io flag |
|
@bazel-io fork 5.3.0 |
|
Hello @benjaminp, I am trying to cherry pick these changes to release-5.3.0 but presubmit checks are failing. Could you please help me in cherry picking these changes with appropriate commits. Thanks! |
* Chunker: Always seek on the uncompressed stream. The `WriteRequest.write_offset` field has bizarre semantics during compressed uploads as documented in the remote API protos: https://github.com/bazelbuild/remote-apis/blob/3b4b6402103539d66fcdd1a4d945f660742665ca/build/bazel/remote/execution/v2/remote_execution.proto#L241-L248 In particular, the write offset of the first `WriteRequest` refers to the offset in the uncompressed source. This change ensures we always seek the uncompressed stream to the correct offset when starting an upload call. The old code could fail to resume compressed uploads under some conditions. The `progressiveCompressedUploadShouldWork` test purported to exercise this situation. The test, however, contained the same logic error as the code under test. Closes #15669. PiperOrigin-RevId: 455083727 Change-Id: Ie22dacf31f15644c7a83f49776e7a633d8bb4bca * Updated chunker.java file. * Update src/test/java/com/google/devtools/build/lib/remote/ByteStreamUploaderTest.java Co-authored-by: Benjamin Peterson <benjamin@locrian.net> * Update src/test/java/com/google/devtools/build/lib/remote/ByteStreamUploaderTest.java Co-authored-by: Benjamin Peterson <benjamin@locrian.net> * Update src/test/java/com/google/devtools/build/lib/remote/ByteStreamUploaderTest.java Co-authored-by: Benjamin Peterson <benjamin@locrian.net> Co-authored-by: Benjamin Peterson <benjamin@engflow.com> Co-authored-by: Benjamin Peterson <benjamin@locrian.net>
| public void seek(long toOffset) throws IOException { | ||
| if (toOffset < offset) { | ||
| if (initialized && toOffset >= offset && !compressed) { | ||
| ByteStreams.skipFully(data, toOffset - offset); |
There was a problem hiding this comment.
Was just reviewing the release notes today for bazel 5.3.0 and came across this.
it looks like with this change, offset no longer updated here when skipFully is called. Just want to sanity check that this is the intentional behavior? (I am not super familiar with bazel internals and how seek is called, but just worried this would result in extra bytes discarded if offset is not updated)
There was a problem hiding this comment.
Thanks; this is a bug. It think it's unlikely to be triggered in practice, since seeking an initialized chunker forward is rare.
The
WriteRequest.write_offsetfield has bizarre semantics during compressed uploads as documented in the remote API protos: https://github.com/bazelbuild/remote-apis/blob/3b4b6402103539d66fcdd1a4d945f660742665ca/build/bazel/remote/execution/v2/remote_execution.proto#L241-L248 In particular, the write offset of the firstWriteRequestrefers to the offset in the uncompressed source.This change ensures we always seek the uncompressed stream to the correct offset when starting an upload call. The old code could fail to resume compressed uploads under some conditions. The
progressiveCompressedUploadShouldWorktest purported to exercise this situation. The test, however, contained the same logic error as the code under test.