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

query promise chaining #345

Conversation

FutureGadget
Copy link
Contributor

As @oshai suggested at #343 (comment), I implemented query chaining. This can solve the problem mentioned in #343 (comment) without introducing scheduler and query execution queue.

Copy link
Contributor

@oshai oshai left a comment

Choose a reason for hiding this comment

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

generally lgtm.

Initially I thought to do that only for cancellation, but the proposed cl is doing it for all queries.
This looks like a more gracefull way to go, and the commit is cleaner. On the other hand in some edge cases this might hide issues because now it allows trying to send queries in parallel (it will just chain them).

Since it doesn't break any test I think we can go with that. the info log message might assist in case someone see something unexpected and I hope this is enough.

): CompletableFuture<QueryResult> {
return try {
if (isQuerying()) {
queryPromise().get().flatMap { func(param) }
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add a info log here, that we are doing a chaining?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your review and inspiring comments. I've tested this fix and it has some side effects as you said.
I think #347 is a better option.

@FutureGadget
Copy link
Contributor Author

generally lgtm.

Initially I thought to do that only for cancellation, but the proposed cl is doing it for all queries. This looks like a more gracefull way to go, and the commit is cleaner. On the other hand in some edge cases this might hide issues because now it allows trying to send queries in parallel (it will just chain them).

Since it doesn't break any test I think we can go with that. the info log message might assist in case someone see something unexpected and I hope this is enough.

Like you said, I also think that this fix is prone to side effects.
I've tested this with r2dbc-pool and it showed some unexpected behaviors.
For example, the first query (not the chained queries but the very first one) got timed out even after the subscription has been cancelled and ROLLBACK and SET AUTOCOMMIT = 1 queries were not executed.

Since what I expected was that once the first query is cancelled, the ROLLBACK and SET AUTOCOMMIT = 1
queries should be chained and executed one by one, so that the connection can be reused later.

For that reason, I've implemented and tested your another suggestion, which is close connection on query conflict.
I would be appreciated if you take a look on #347.
Thank you!

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.

None yet

2 participants