-
Notifications
You must be signed in to change notification settings - Fork 17
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
Force driver to use Vert.x event loop #4
Conversation
…lient into integrate_driver_and_vertx_threads
…lient into integrate_driver_and_vertx_threads
@vietj , @tsegismont , can you review? |
so if we use this event loop, what are we doing a on cassandra event loop callback ? can you point out code ? |
You mean in which thread we are, when a callback is called? |
This is how driver's bootstrap is configured: https://github.com/datastax/java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/Connection.java#L1032 |
I was actually referring to the code called back from Cassandra like:
in the final callback to the user code:
do you use |
Ah, I got it. Sure, we need to call |
I also think that driver should use acceptor event loop because we can't specify one for networking and one for calling handlers |
@vietj , can you review, please? |
@vietj , ping |
I think we should have tests with callbacks that: 1/ check the context is the right one |
@vietj , done. Can you review one more time, please? |
} else { | ||
if (resultHandler != null) { | ||
resultHandler.handle(Future.failedFuture(executionResult.cause())); | ||
vertxExecuteFuture.setHandler(executionResult -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simplify to :
vertxExecuteFuture.setHandler(executionResult -> {
if (resultHandler != null) {
ctx.executeFromIO(executionResult, resultHandler);
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
there are simplifications you can do in callbacks, there is a method on |
@vietj, can you review once again? |
@tsegismont , can you review, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sammers21 the changes look good to me, but it would be better to create a dedicated test for context checking.
@@ -50,10 +50,12 @@ private void connectAndDisconnect(TestContext context, CassandraClientOptions op | |||
); | |||
Async async = context.async(2); | |||
cassandraClient.connect("system", connectEvent -> { | |||
checkContext(context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe it is necessary to do this in all the tests in the test suite. Instead, we could have a test dedicated to context checking (with different use cases for shared/non shared client)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe it is necessary to do this in all the tests in the test suite. Instead, we could have a test dedicated to context checking
Agree.
with different use cases for shared/non shared client
Why do we need to have context checks for both of them?
It seems that there is something wrong with this approach. We are getting IllegalStateExceptions:
https://travis-ci.org/vert-x3/vertx-cassandra-client/jobs/437563597 |
@vietj , @tsegismont do you have any ideas on what is wrong? |
I am also not able to reproduce it on my on my laptop (tried 10 times). looks weird. |
@Sammers21 looking |
I can reproduce on my box with a vertx-unit repeat rule. Working on the fix. |
@Sammers21 the issue is here: vertx-cassandra-client/src/main/java/io/vertx/cassandra/impl/CassandraClientImpl.java Lines 160 to 164 in 7f7fb20
When The issue is not specific to this PR, it is simply brought forward because |
@Sammers21 I believe the acceptor event loop group shouldn't be used vertx-cassandra-client/src/main/java/io/vertx/cassandra/impl/CassandraClientImpl.java Lines 280 to 283 in 7f7fb20
It's a single thread group and we don't all Datastax connections to handled by a single event loop |
@Sammers21 I overlooked key changes the first time I reviewed this PR. For this to work we must be sure that the Datastax driver callbacks will always be invoked on the connection event loop. I don't believe this is true. |
you can use EventExecutor#inEventLoop() to check wether yo uare in event loop or not.
Julien
… On 8 Oct 2018, at 14:30, Thomas Segismont ***@***.***> wrote:
@Sammers21 <https://github.com/Sammers21> I overlooked key changes the first time I reviewed this PR. For this to work we must be sure that the Datastax driver callbacks will always be invoked on the connection event loop. I don't believe this is true.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#4 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AANxipk4atFTgwP_3nMrCt0naMwVhWGZks5ui0VTgaJpZM4WBHjM>.
|
@vietj right. But my point was that chances are low that the event loop running the driver connection is the same as the event loop running the calling context. In the end, to make this right, we'll add a lot of complexity for a small benefit. @Sammers21 @vietj I just submitted #9 and I would rather close this one |
@tsegismont, the #9 PR is fine to me. But, can we make the problem more explicit? A Vert.x instance maintain the acceptor event loop, which is a single-threaded event loop. The event loop should be used for network operations and never be used for executing user code. Right? Why can't we use the acceptor event loop for network operations with Cassandra and delegate "calling handlers" to a context related event loop, so user code(inside one verticle) will always be executed in the same context. |
The Its purpose is to avoid having connections (HTTP servers, net servers) rejected because all the event loops used for verticles are too busy. It should not be reused in the Cassandra client to create event loop for driver connections. vertx-cassandra-client/src/main/java/io/vertx/cassandra/impl/CassandraClientImpl.java Lines 280 to 283 in 7f7fb20
So the code above is wrong. If anything, we should use
Not sure what you mean.
I believe I answered the question related to The problems are:
Therefore, the benefits (a bit less threads) are not going to outweigh the added complexity. |
@Sammers21 I'll go ahead and merge #9 We can either close #3, or keep it open and try to demonstrate the benefits with a benchmark? |
@tsegismont , I we can close this PR, and keep the #3 issue open. |
@tsegismont, yes I think we need to measure performance benefits |
Fixes #3