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

fix: client rpcserver subscriber hang #3246

Merged
merged 4 commits into from
May 7, 2024

Conversation

jim3ma
Copy link
Member

@jim3ma jim3ma commented Apr 30, 2024

Description

  1. One remote peer come with StartNum > 0, eg: StartNum = 1
  2. Local peer run sendRemainingPieceTasks and s.totalPieces is -1
  3. Local peer start to back source or download from other peers with piece 0
  4. For piece 0 from local peer, due to s.totalPieces is -1, the following check will be skipped and will be sent to remote peer: if s.totalPieces > -1 && uint32(info.Num) < nextPieceNum, then len(s.sentMap)++
  5. s.totalPieces will be updated
  6. because the piece 0 which should not be sent in step 4, will hit the following logic to break loop
     if s.totalPieces > -1 && len(s.sentMap)+int(s.skipPieceCount) == int(s.totalPieces) {
        s.Unlock()
        break loop
    }
  1. The subscriber will hang until other peers send more pieces.

Solution:

We should not check completeness via fuzzy len(s.sentMap), and check the next piece num is a better method.

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@jim3ma jim3ma requested a review from a team as a code owner April 30, 2024 14:40
@jim3ma jim3ma requested review from imeoer, hhhhsdxxxx and hyy0322 April 30, 2024 14:40
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 52.83%. Comparing base (22f46b7) to head (53a4880).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3246      +/-   ##
==========================================
- Coverage   52.86%   52.83%   -0.04%     
==========================================
  Files         192      192              
  Lines       20341    20351      +10     
==========================================
- Hits        10754    10753       -1     
- Misses       8788     8796       +8     
- Partials      799      802       +3     
Flag Coverage Δ
unittests 52.83% <66.66%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/daemon/rpcserver/subscriber.go 56.96% <66.66%> (+2.90%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@xujihui1985 xujihui1985 left a comment

Choose a reason for hiding this comment

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

LTGM

@xujihui1985 xujihui1985 merged commit 1e6f09d into main May 7, 2024
27 checks passed
@xujihui1985 xujihui1985 deleted the fix/client-rpcserver-subscriber-hang branch May 7, 2024 02:18
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.

3 participants