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

Simplify graphsync cancel #229

Merged
merged 4 commits into from
Aug 6, 2021
Merged

Simplify graphsync cancel #229

merged 4 commits into from
Aug 6, 2021

Conversation

dirkmc
Copy link
Contributor

@dirkmc dirkmc commented Aug 5, 2021

@@ -95,9 +95,9 @@ var ChannelEvents = fsm.Events{
chst.AddLog("data transfer receive error: %s", chst.Message)
return nil
}),
fsm.Event(datatransfer.RequestTimedOut).FromAny().ToNoChange().Action(func(chst *internal.ChannelState, err error) error {
fsm.Event(datatransfer.RequestCancelled).FromAny().ToNoChange().Action(func(chst *internal.ChannelState, err error) error {
Copy link
Member

Choose a reason for hiding this comment

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

Since we are changing this state transition and RequestTimedOut is abandoned now, should we migrate all RequestTimedOut to RequestCancelled, so that they're not left in limbo? Or are these terminal states?

Alternatively, we could rename RequestTimedOut to RequestCancelled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RequestTimedOut & RequestCancelled are events, not states, so I don't think they will get recorded anywhere. I don't think we need to migrate anything.

// Error returns are logged but otherwise have no effect
OnRequestTimedOut(chid ChannelID, err error) error
OnRequestCancelled(chid ChannelID, err error) error
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to percolate this change up to go-fil-markets, or lotus?

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 interface is only used internally so I don't think we need to make changes anywhere else

Copy link
Member

Choose a reason for hiding this comment

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

Ack.

func (t *Transport) executeGsRequest(req *gsReq) {
defer req.onComplete()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not an expert in go-data-transfer, but what replaces the onComplete call here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that graphsync.CancelRequest() waits until the event queue is drained, we don't need to detect complete manually so we no longer need this callback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it is safer to wait for both the events to be drained, and the channel returned from graphsync.Request() to be drained. So in the end I think it does make sense to keep the onComplete mechanism 👍
I've restored it now.

transport/graphsync/graphsync.go Outdated Show resolved Hide resolved
@@ -981,7 +920,7 @@ func (c *dtChannel) gsDataRequestRcvd(gsKey graphsyncKey, hookActions graphsync.

// Save a mapping from the graphsync key to the channel ID so that
// subsequent graphsync callbacks are associated with this channel
c.gsKey = gsKey
c.gsKey = &gsKey
Copy link
Member

Choose a reason for hiding this comment

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

We don't seem to have acquired the lock before writing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lock is acquired on line 515. The code in this file is super complicated to follow.

Copy link
Member

Choose a reason for hiding this comment

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

Ack.

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2021

Codecov Report

Merging #229 (a92d493) into master (1d44c41) will decrease coverage by 0.34%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #229      +/-   ##
==========================================
- Coverage   67.61%   67.26%   -0.35%     
==========================================
  Files          24       24              
  Lines        3032     3040       +8     
==========================================
- Hits         2050     2045       -5     
- Misses        632      639       +7     
- Partials      350      356       +6     
Impacted Files Coverage Δ
channels/channels.go 72.72% <0.00%> (ø)
channels/channels_fsm.go 65.06% <0.00%> (ø)
transport/graphsync/graphsync.go 77.75% <70.21%> (-1.35%) ⬇️
impl/events.go 74.58% <100.00%> (ø)
network/libp2p_impl.go 68.38% <0.00%> (-2.95%) ⬇️

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 1d44c41...a92d493. Read the comment docs.

@dirkmc dirkmc marked this pull request as ready for review August 6, 2021 08:49
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