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

FAB-18291 Ch.Part.API: BlockPuller that can be stopped, improve follower Halt() responsiveness #2050

Merged
merged 1 commit into from
Oct 29, 2020
Merged

Conversation

tock-ibm
Copy link
Contributor

@tock-ibm tock-ibm commented Oct 27, 2020

When a follower is started with a block that has bad endpoints,
it will cause the internal BlockPuller to retry a lot of times.
Calling Halt() on said follower will block until the BlockPuller
gives up, which can take a very long time. This causes an attempt
to Remove that channel via the participation API to block for too long.

This commit improves the BlockPuller by adding a channel to signal
it to stop retrying and exit. It also integrates with the
follower.Chain to make it more responsive to Halt().

Signed-off-by: Yoav Tock tock@il.ibm.com
Change-Id: I49354d94a28402ce69a469689c12ea595b3e0a7e

Type of change

  • Bug fix
  • Improvement (improvement to code, performance, etc)

Related issues

FAB-18291

@tock-ibm tock-ibm requested a review from a team as a code owner October 27, 2020 18:06
@tock-ibm tock-ibm marked this pull request as draft October 27, 2020 18:07
@tock-ibm tock-ibm changed the title WIP: BlockPuller that can be stopped FAB-18291 Ch.Part.API: BlockPuller that can be stopped, improve follower Halt() responsiveness Oct 27, 2020
@tock-ibm tock-ibm marked this pull request as ready for review October 27, 2020 20:03
wlahti
wlahti previously approved these changes Oct 27, 2020
Copy link
Contributor

@wlahti wlahti left a comment

Choose a reason for hiding this comment

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

Works for me. Manually verified this resolves the issue that led me to open the JIRA item.

// A 'stopper' goroutine may signal the go-routine servicing PullBlock & HeightsByEndpoints to stop by closing this
// channel. Note: all methods of the BlockPuller must be serviced by a single goroutine, it is not thread safe.
// It is the responsibility of the 'stopper' not to close the channel more then once.
StopChannel chan struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

The way of externally closing an internal channel is somewhat crude. I think that we should maintain the channel ourselves from within this struct, that is, to close it in a "Close" instance method.

Copy link
Contributor Author

@tock-ibm tock-ibm Oct 28, 2020

Choose a reason for hiding this comment

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

It is not necessarily an internal channel. It is possible to give the BlockPuller an external channel, in the case of the follower, the channel that signals the follower itself to stop. This way that channel is closed when someone calls follower.Halt() and it signals both the follower and the block puller it holds to stop retrying and exit. This is fine because in the follower we have only a single goroutine that goes in and out of the block puller.

When a follower is started with a block that has bad endpoints,
it will cause the internal BlockPuller to retry a lot of times.
Calling Halt() on said follower will block until the BlockPuller
gives up, which can take a very long time. This causes an attempt
to Remove that channel via the participation API to block for too long.

This commit improves the BlockPuller by adding a channel to signal
it to stop retrying and exit. It also integrates with the
follower.Chain to make it more resposive to Halt().

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I49354d94a28402ce69a469689c12ea595b3e0a7e
@yacovm yacovm merged commit 2bf53e6 into hyperledger:master Oct 29, 2020
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.

4 participants