Skip to content
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

transport/bufWriter: fast-fail on error returned from flushKeepBuffer() #7394

Merged
merged 11 commits into from
Aug 7, 2024

Conversation

veshij
Copy link
Contributor

@veshij veshij commented Jul 5, 2024

fixes #7389

RELEASE NOTES:

  • transport: Fix a bug which could result in writes busy looping when the underlying conn.Write returns errors

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.42%. Comparing base (bdd707e) to head (877dd6f).
Report is 38 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #7394    +/-   ##
========================================
  Coverage   81.42%   81.42%            
========================================
  Files         348      354     +6     
  Lines       26744    27083   +339     
========================================
+ Hits        21775    22053   +278     
- Misses       3779     3817    +38     
- Partials     1190     1213    +23     
Files Coverage Δ
internal/transport/http_util.go 93.30% <100.00%> (+6.89%) ⬆️

... and 41 files with indirect coverage changes

@arjan-bal arjan-bal self-assigned this Jul 8, 2024
@arjan-bal arjan-bal self-requested a review July 8, 2024 05:27
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

Thank you for sending the fix, left some minor comments.

internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util.go Outdated Show resolved Hide resolved
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
@arjan-bal arjan-bal assigned veshij and unassigned arjan-bal Jul 8, 2024
@arjan-bal arjan-bal added this to the 1.66 Release milestone Jul 8, 2024
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

LGTM, adding another reviewer for a second approval.

@arjan-bal arjan-bal assigned easwars and unassigned veshij Jul 9, 2024
@arjan-bal arjan-bal requested a review from easwars July 9, 2024 09:01
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util_test.go Show resolved Hide resolved
internal/transport/http_util_test.go Outdated Show resolved Hide resolved
internal/transport/http_util.go Show resolved Hide resolved
func (s) TestWriteBadConnection(t *testing.T) {
data := []byte("test_data")
writeBufferSize := (len(data) - 1) / 2
writer := newBufWriter(&badNetworkConn{}, writeBufferSize, getWriteBufferPool(writeBufferSize))
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably can add a test table, where we create the bufWriter with and without a shared pool and ensure that the behavior works across both cases.

@easwars easwars assigned veshij and unassigned easwars Jul 9, 2024
@dfawley dfawley assigned easwars and unassigned veshij Jul 16, 2024
internal/transport/http_util.go Outdated Show resolved Hide resolved
@easwars
Copy link
Contributor

easwars commented Jul 16, 2024

Also, please respond to individual comments. That helps reviewers to keep track of the individual changes that they requested (and eventually mark them as resolved). Thanks.

@easwars easwars assigned easwars and unassigned easwars Jul 19, 2024
@easwars
Copy link
Contributor

easwars commented Jul 23, 2024

Looks like a bunch of tests are failing. PTAL.

internal/transport/http_util.go Outdated Show resolved Hide resolved
internal/transport/http_util.go Outdated Show resolved Hide resolved
@veshij
Copy link
Contributor Author

veshij commented Jul 24, 2024

looking at failed tests

@dfawley
Copy link
Member

dfawley commented Jul 30, 2024

@veshij any update?

@veshij
Copy link
Contributor Author

veshij commented Aug 1, 2024

@veshij any update?

@dfawley
*bufWriter.Write implementation can completely skip flushing if w.offset >= w.batchSize condition is never met.
In this case once this buffer is reused later on - flushKeepBuffer() would return more bytes than was initially sent to Write() call. Thus we can't reuse value returned from flushKeepBuffer().
One option would be to leave total written bytes accounting as is (always written += copied), or force-flush buffer at the end of Write call (which is likely too expensive).

Updated PR with the first option.

@easwars
Copy link
Contributor

easwars commented Aug 7, 2024

@printchard : FYI

@easwars easwars assigned arvindbr8 and unassigned easwars Aug 7, 2024
@arvindbr8 arvindbr8 changed the title [http_util/bufWriter] fast-fail on error returned from flushKeepBuffer() transport/bufWriter: fast-fail on error returned from flushKeepBuffer() Aug 7, 2024
@arvindbr8 arvindbr8 merged commit ffaa81e into grpc:master Aug 7, 2024
13 checks passed
infovivek2020 pushed a commit to infovivek2020/grpc-go that referenced this pull request Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop in bufWriter.Write()
6 participants