Skip to content

Backpressure for reading records #438

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 3 commits into from
Nov 29, 2017
Merged

Conversation

lutovich
Copy link
Contributor

Previously driver would read records from network even if client did not consume them. This happened because event loop threads were always in auto-read mode despite the amount of currently buffered records. This could lead to memory problems when handling large results that are slowly consumed.

This PR adds simple network-level backpressure for reading records. Auto-read mode is turned off when amount of buffered records reaches high watermark. It is turned on again when bunch of records are consumed and buffer size reaches low watermark. Also added unit tests for PULL_ALL and RUN handlers.

@lutovich lutovich requested a review from ali-ince November 29, 2017 12:23
Previously parsing of SUCCESS message metadata was done in
`PullAllResponseHandler` which violates single responsibility principle.

This commit extracts it in a dedicated helper class and adds unit tests.
Previously driver would read records from network even if client did
not consume them. This happened because event loop threads were always
in auto-read mode despite the amount of currently buffered records.
This could lead to memory problems when handling large results that
are slowly consumed.

This commit adds simple network-level backpressure for reading records.
Auto-read mode is turned off when amount of buffered records reaches
high watermark. It is turned on again when bunch of records are
consumed and buffer size reaches low watermark. Also added unit tests
for PULL_ALL and RUN handlers.
Moved parsing of RUN message metadata to a class responsible for
SUCCESS metadata parsing. This way all such parsing is in a
single class. Renamed this utility class to `MetadataUtil`.
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!

@ali-ince ali-ince merged commit ae43d77 into neo4j:1.5 Nov 29, 2017
@lutovich lutovich deleted the 1.5-auto-read branch November 29, 2017 21:50
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