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

Close eventfd shutdown/wakeup race by closely tracking epoll edges #9535

Merged
merged 1 commit into from Sep 5, 2019

Conversation

njhill
Copy link
Member

@njhill njhill commented Sep 4, 2019

Motivation

This is another iteration of #9476.

Modifications

Instead of maintaining a count of all writes performed and then using reads during shutdown to ensure all are accounted for, just set a flag after each write and don't reset it until the corresponding event has been returned from epoll_wait.

This requires that while a write is still pending we don't reset wakenUp, i.e. continue to block writes from the wakeup() method.

Result

Race condition eliminated. Fixes #9362

Motivation

This is another iteration of netty#9476.

Modifications

Instead of maintaining a count of all writes performed and then using
reads during shutdown to ensure all are accounted for, just set a flag
after each write and don't reset it until the corresponding event has
been returned from epoll_wait.

This requires that while a write is still pending we don't reset
wakenUp, i.e. continue to block writes from the wakeup() method.

Result

Race condition eliminated. Fixes netty#9362
@netty-bot
Copy link

Can one of the admins verify this patch?

@normanmaurer
Copy link
Member

@netty-bot test this please

@normanmaurer normanmaurer added this to the 4.1.40.Final milestone Sep 4, 2019
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

@normanmaurer normanmaurer merged commit 2123fbe into netty:4.1 Sep 5, 2019
@normanmaurer
Copy link
Member

@njhill nice job! Please put it on your list for "back ports to do for master" :)

@njhill njhill deleted the eventfd-close-race2 branch September 5, 2019 17:21
normanmaurer added a commit that referenced this pull request Sep 12, 2019
normanmaurer added a commit that referenced this pull request Sep 12, 2019
@normanmaurer normanmaurer removed this from the 4.1.41.Final milestone Sep 12, 2019
@njhill njhill mentioned this pull request Sep 12, 2019
johnou added a commit to johnou/netty that referenced this pull request Sep 19, 2019
njhill added a commit to njhill/netty that referenced this pull request Sep 27, 2019
Motivation

This is a vestige that was removed in the original PR netty#9535 before it
was reverted, but we missed it when re-applying in netty#9586.

It means there is a possible race condition because a wakeup event could
be missed while shutting down, but the consequences aren't serious since
there's a 1 second safeguard timeout when waiting for it.

Modification

Remove call to epollWaitNow() in EpollEventLoop#closeAll()

Result

Cleanup redundant code, avoid shutdown delay race condition
normanmaurer pushed a commit that referenced this pull request Oct 7, 2019
)

Motivation

This is a vestige that was removed in the original PR #9535 before it
was reverted, but we missed it when re-applying in #9586.

It means there is a possible race condition because a wakeup event could
be missed while shutting down, but the consequences aren't serious since
there's a 1 second safeguard timeout when waiting for it.

Modification

Remove call to epollWaitNow() in EpollEventLoop#closeAll()

Result

Cleanup redundant code, avoid shutdown delay race condition
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.

Shutdown race in EpollEventLoop
4 participants