Skip to content

Conversation

@End-rey
Copy link
Contributor

@End-rey End-rey commented Sep 8, 2025

Closes #3562.

@codecov
Copy link

codecov bot commented Sep 8, 2025

Codecov Report

❌ Patch coverage is 7.46269% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.93%. Comparing base (bb155f3) to head (851d110).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/object/get/util.go 0.00% 51 Missing ⚠️
pkg/services/object/get/exec.go 33.33% 6 Missing and 2 partials ⚠️
pkg/services/object/get/assembly_v2.go 0.00% 2 Missing ⚠️
pkg/services/object/get/assemble.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3568      +/-   ##
==========================================
- Coverage   25.98%   25.93%   -0.06%     
==========================================
  Files         660      660              
  Lines       49738    49729       -9     
==========================================
- Hits        12926    12898      -28     
- Misses      35775    35792      +17     
- Partials     1037     1039       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@End-rey End-rey marked this pull request as draft September 8, 2025 17:42
@End-rey End-rey force-pushed the fix-stream-problems branch 6 times, most recently from daa80da to 847d5a4 Compare September 11, 2025 14:32
@End-rey
Copy link
Contributor Author

End-rey commented Sep 11, 2025

@End-rey End-rey marked this pull request as ready for review September 11, 2025 14:33
@roman-khimov
Copy link
Member

Multiple focused commits (in a single PR) would be easier to digest, there are different problems being solved here.

if err != nil {
return fmt.Errorf("read next payload chunk: %w", err)
}
if n == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fix problem with s3 uploading multipart objects. Idk why, but in this case, a reader appears that reads zero bytes without errors, resulting in an infinite loop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an error? This shouldn't happen. Likely this means some reader implementation is broken in our code and we're not returning io.EOF properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens when the payload size is zero and the buffer size then becomes zero

bufSize = min(streamChunkSize, obj.PayloadSize())

And here the result is returned without EOF
https://github.com/nspcc-dev/neofs-sdk-go/blob/666fbf83b88bbbb51b7d0ef6d5ecf371e1435231/client/object_get.go#L196-L202

Copy link
Member

@roman-khimov roman-khimov Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://pkg.go.dev/io#Reader

Implementations of Read are discouraged from returning a zero byte count with a nil error, except when len(p) == 0. Callers should treat a return of 0 and nil as indicating that nothing happened; in particular it does not indicate EOF.

https://go.dev/play/p/PqARo45a-Xv

Looks like it's a caller problem, if it knows the size is zero it should not call Read(). If it doesn't know the size (it's a stream after all), it should pass some buffer and get EOF. Now the question is where these rules should be applied in our codebase, we have a number of different readers. But just treating n == 0 as a signal of its own here seems wrong to me.

Copy link
Contributor

@cthulhu-rider cthulhu-rider Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing empty buffer is nonsense. The easiest thing to do is max(x, 1).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If bufSize is 0 (and if this only happens when payload is zero) then we can skip the reader loop altogether, just return nil.

Copy link
Contributor

@cthulhu-rider cthulhu-rider Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this'd be another change cuz explicit reading also checks that exactly PayloadSize() bytes are streamed, 0 in particular

@End-rey End-rey force-pushed the fix-stream-problems branch from 847d5a4 to 9306bda Compare September 11, 2025 14:57
Fix problems with writing children logic with new stream logic.

Refs #3562.

Signed-off-by: Andrey Butusov <[email protected]>
if err != nil {
return fmt.Errorf("read next payload chunk: %w", err)
}
if n == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an error? This shouldn't happen. Likely this means some reader implementation is broken in our code and we're not returning io.EOF properly.

@End-rey End-rey force-pushed the fix-stream-problems branch from 9306bda to 773c361 Compare September 11, 2025 21:16
@End-rey End-rey force-pushed the fix-stream-problems branch 3 times, most recently from 1432be2 to 851d110 Compare September 12, 2025 11:24
Fix that the range request with new stream logic don't fall
back to GET after `apistatus.ErrObjectAccessDenied`.

Refs #3562.

Signed-off-by: Andrey Butusov <[email protected]>
Fix an infinite loop while reading from the reader if the size of the written
bytes is zero and there is no error. The buffer size can no longer be 0.

Closes #3562.

Signed-off-by: Andrey Butusov <[email protected]>
@roman-khimov roman-khimov merged commit 17a9b61 into master Sep 12, 2025
16 of 19 checks passed
@roman-khimov roman-khimov deleted the fix-stream-problems branch September 12, 2025 11:56
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.

Regressions from streaming merge

4 participants