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

Accept max in-flight requests on the connection #216

Merged
merged 10 commits into from
Nov 27, 2018

Conversation

tulios
Copy link
Owner

@tulios tulios commented Nov 26, 2018

This PR adds support to max in-flight requests. The option is set to null now so we can test it out, I want to understand the impact of more or less concurrent requests before we commit to a default value.

Copy link
Contributor

@ianwsperber ianwsperber left a comment

Choose a reason for hiding this comment

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

Stoked to see this PR @tulios! It's a cool feature. I don't see any real blockers, just left a few thoughts and suggestions.

src/network/requestQueue/socketRequest.js Outdated Show resolved Hide resolved
src/network/requestQueue/socketRequest.js Show resolved Hide resolved
src/network/requestQueue/index.js Outdated Show resolved Hide resolved
return request
}

push(request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently we advance through the queue essentially by chaining callbacks - when one requests succeeds/fails we add the next pending message to the queue. If for whatever reason an error or bug prevented the expected end condition from being met we could encounter some sort of a deadlock. I do think that in most cases the timeout will account for this, but it does make me wonder if it'd make sense to have some sort of "cleanup" process running on a setInterval to ensure the queue is advancing. Just a thought, I don't think it's necessarily something we have to implement now.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This case is covered, besides the timeout, all requests are rejected on socket errors/timeout (https://github.com/tulios/kafkajs/blob/master/src/network/connection.js#L116), the request queue will reject all inflight and pending requests.

src/network/requestQueue/index.js Outdated Show resolved Hide resolved
@tulios tulios self-assigned this Nov 27, 2018
@tulios
Copy link
Owner Author

tulios commented Nov 27, 2018

@ianwsperber @Nevon I addressed all the comments, please take another look

const current = this[PRIVATE.STATE].toString()

throw new KafkaJSNonRetriableError(
`Invalid state, can't transition from ${current} to ${next.toString()}`
Copy link
Contributor

Choose a reason for hiding this comment

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

So basically we only provide next for logging purposes, since we only validate accepted

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, just to improve the error message

Copy link
Contributor

@ianwsperber ianwsperber left a comment

Choose a reason for hiding this comment

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

Thanks for making those updates @tulios! Looks good to me 👍

@tulios tulios merged commit 1c6b1cf into master Nov 27, 2018
@tulios tulios deleted the accept-max-in-flight-requests-on-the-connection branch November 29, 2018 08:43
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.

2 participants