-
Notifications
You must be signed in to change notification settings - Fork 460
fix(storage): compression upload & cache correctness fixes #3231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ca9c3fa
fix(storage): verify frame checksum on decompress reader Close
dobrac 4150d52
fix(storage): reject unaligned compressed frame offsets
dobrac cc5b234
fix(storage): don't cache compressed frames that fail to decompress
dobrac 95fafec
fix(orchestrator): verify compressed frame before releasing chunk wai…
dobrac 3c520ae
fix(storage): send explicit Content-Length on GCS multipart parts
dobrac 5105c2e
fix(storage): reject GCS complete-upload 200 with error body
dobrac 16bc458
fix(storage): send Content-Length on empty GCS multipart part
dobrac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package storage | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "crypto/sha256" | ||
| "io" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestDecompressReaderVerifiesCRCOnClose ensures a footer-corrupt frame is not | ||
| // reported as success when the caller reads exactly the uncompressed size. | ||
| // zstd only verifies the frame checksum once the footer is consumed, which an | ||
| // exact-size read never triggers, so Close must drain-verify and surface the | ||
| // error. | ||
| func TestDecompressReaderVerifiesCRCOnClose(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| const frameU = 512 * 1024 | ||
| data := generateSemiRandomData(frameU) | ||
|
|
||
| up := &memPartUploader{} | ||
| fullFT, _, err := compressStream(t.Context(), bytes.NewReader(data), defaultCfg(CompressionZstd, 1, frameU), up, 1, nil) | ||
| require.NoError(t, err) | ||
| require.Equal(t, 1, fullFT.Table().NumFrames()) | ||
| blob := up.Assemble() | ||
|
|
||
| // Corrupt the frame footer (last byte) so only the trailing checksum, | ||
| // verified after the last content byte, is wrong. | ||
| corrupt := bytes.Clone(blob) | ||
| corrupt[len(corrupt)-1] ^= 0xFF | ||
|
|
||
| dec, err := NewDecompressReader(bytesRangeReader(corrupt), CompressionZstd, SourceAWS, SeekableObjectType(0)) | ||
| require.NoError(t, err) | ||
|
|
||
| // Read EXACTLY the uncompressed frame size — no read past EOF. | ||
| buf := make([]byte, frameU) | ||
| _, _ = io.ReadFull(dec, buf) | ||
| _, closeErr := dec.Close(t.Context()) | ||
| require.Error(t, closeErr, "exact-size read of a footer-corrupt frame must fail on Close") | ||
|
|
||
| // A clean frame still round-trips and closes without error. | ||
| dec2, err := NewDecompressReader(bytesRangeReader(blob), CompressionZstd, SourceAWS, SeekableObjectType(0)) | ||
| require.NoError(t, err) | ||
| got := make([]byte, frameU) | ||
| _, err = io.ReadFull(dec2, got) | ||
| require.NoError(t, err) | ||
| _, closeErr = dec2.Close(t.Context()) | ||
| require.NoError(t, closeErr) | ||
| require.Equal(t, sha256.Sum256(data), sha256.Sum256(got)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.