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: pullsync context cancellation #2562

Merged
merged 2 commits into from Oct 5, 2021
Merged

fix: pullsync context cancellation #2562

merged 2 commits into from Oct 5, 2021

Conversation

acud
Copy link
Member

@acud acud commented Oct 3, 2021

This change is Reviewable

@acud acud added the ready for review The PR is ready to be reviewed label Oct 4, 2021
Copy link
Contributor

@mrekucci mrekucci left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @acud)


pkg/pullsync/metrics.go, line 13 at r1 (raw file):

type metrics struct {
	OfferCounter         prometheus.Counter // number of chunks offered

I'd suggest to avoid the Counter suffix here and in the fields below since it is kind of implicit and we don't expect to have anything else in the metrics


pkg/pullsync/pullsync.go, line 521 at r1 (raw file):

			_ = stream.Reset()
			if logMore {
				s.logger.Debugf("pullsync: peer %d failed cancelling %d: %v", p.Address.String(), c.Ruid, err)

The verb for sting (address) should be %s, not %d.


pkg/pullsync/pullsync.go, line 533 at r1 (raw file):

	if logMore {
		s.logger.Debugf("pullsync: peer %d cancelling %d", p.Address.String(), c.Ruid)

Same here.

Copy link
Member Author

@acud acud left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @mrekucci)


pkg/pullsync/metrics.go, line 13 at r1 (raw file):

Previously, mrekucci wrote…

I'd suggest to avoid the Counter suffix here and in the fields below since it is kind of implicit and we don't expect to have anything else in the metrics

agree and done


pkg/pullsync/pullsync.go, line 521 at r1 (raw file):

Previously, mrekucci wrote…

The verb for sting (address) should be %s, not %d.

Done.


pkg/pullsync/pullsync.go, line 533 at r1 (raw file):

Previously, mrekucci wrote…

Same here.

Done.

@sonarcloud
Copy link

sonarcloud bot commented Oct 5, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@11f9aa8). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2562   +/-   ##
=========================================
  Coverage          ?   63.77%           
=========================================
  Files             ?      232           
  Lines             ?    25797           
  Branches          ?        0           
=========================================
  Hits              ?    16451           
  Misses            ?     7860           
  Partials          ?     1486           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11f9aa8...f84e8cb. Read the comment docs.

@acud acud requested a review from mrekucci October 5, 2021 08:46
s.ruidMtx.Lock()
defer s.ruidMtx.Unlock()

if cancel, ok := s.ruidCtx[c.Ruid]; ok {
if cancel, ok := s.ruidCtx[p.Address.ByteString()][c.Ruid]; ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still being a novice golang coder, does this handle if an unknown (s.ruidCtx[p.Address.ByteString()] is null) peer from asking us to cancel a [c.Ruid]? Or will the if try to access nil[c.Ruid]?

Copy link
Member Author

@acud acud Oct 5, 2021

Choose a reason for hiding this comment

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

https://play.golang.org/p/hm2GrMxoTJA I don't see a case where the peer address is unknown. If this happens we have a much bigger problem on our hands and I'd rather have this explicitly panic so that we know the problem is there. Otherwise as there's no pointer dereferencing here there's no chance of panicking

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just echoing years of my C coding where you always validate the first map/subscript is not null before referencing the next level down.

Copy link
Contributor

@mrekucci mrekucci left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acud)

@acud acud merged commit d81e579 into master Oct 5, 2021
@acud acud deleted the pullsync-peermetric branch October 5, 2021 14:22
@acud acud added this to the v1.2.0 milestone Oct 8, 2021
aloknerurkar pushed a commit that referenced this pull request Oct 10, 2021
This PR changes the way we do ruid cancellations in pullsync in a way that limits the access to certain ruids only to the overlay address from which the requests came from.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants