Skip to content

Perform writes fully in event loop #408

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

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

lutovich
Copy link
Contributor

NettyConnection is the abstraction over netty channel that allows us to write RUN, PULL_ALL and other messages. Currently write consists of two steps: (1) enqueue a response handler (2) perform actual write. Step (1) is executed in the caller thread and step (2) is always executed in the event loop thread (guaranteed by Netty).

Step (1) involves modification of a non-synchronized LinkedList which is a problem. Later event loop thread will try to pop handlers from the same list meaning we access it from different threads.

This PR make both (1) and (2) execute in the event loop to avoid synchronization issues. It basically makes sure InboundMessageDispatcher is only accessed by the event loop.

Also removed ConcurrentSet implementation in favour of the one existing in Netty.

`NettyConnection` is the abstraction over netty channel that allows us
to write RUN, PULL_ALL and other messages. Currently write consists of
two steps: (1) enqueue a response handler (2) perform actual write.
Step (1) is executed in the caller thread and step (2) is always
executed in the event loop thread (guaranteed by Netty).

Step (1) involves modification of a non-synchronized `LinkedList`
which is a problem. Later event loop thread will try to pop handlers
from the same list meaning we access it from different threads.

This commit make both (1) and (2) execute in the event loop to avoid
synchronization issues. It basically makes sure
`InboundMessageDispatcher` is only accessed by the event loop.

Also removed `ConcurrentSet` implementation in favour of the one
existing in Netty.
@lutovich lutovich force-pushed the 1.5-writes-in-evt-loop branch from 58213ed to 97e5f29 Compare September 27, 2017 16:08
Copy link
Contributor

@ali-ince ali-ince left a comment

Choose a reason for hiding this comment

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

LGTM!

@lutovich lutovich merged commit c79fc2d into neo4j:1.5 Sep 28, 2017
@lutovich lutovich deleted the 1.5-writes-in-evt-loop branch September 28, 2017 09:27
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.

2 participants