-
Notifications
You must be signed in to change notification settings - Fork 119
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
fix Redis connection sharing #421
Conversation
@vietj I believe this implements what we discussed earlier today. I'd really like your review on this :-) When done, I will backport the fix to 4.x. |
Humm. Will investigate the failure next week. |
375d732
to
35b2e4d
Compare
Turns out when I moved from Fixed. |
One more point to discuss maybe, @vietj I recognize this @Override
public Future<Response> send(final Request request) {
if (context == vertx.getContext()) {
return doSend(request);
} else {
Promise<Response> promise = vertx.getOrCreateContext().promise();
context.runOnContext(ignored -> {
try {
doSend(request).onComplete(promise);
} catch (Exception e) {
promise.fail(e);
}
});
return promise.future();
}
} is fairly low-level. If I understand correctly, this @Override
public Future<Response> send(final Request request) {
Promise<Response> promise = vertx.getOrCreateContext().promise();
context.emit(ignored -> {
try {
doSend(request).onComplete(promise);
} catch (Exception e) {
promise.fail(e);
}
});
return promise.future();
} would be a shorter equivalent, except that it always allocates an extra |
35b2e4d
to
833e231
Compare
I decided to backport to 4.x proactively, here goes: #424 |
src/main/java/io/vertx/redis/client/impl/RedisStandaloneConnection.java
Outdated
Show resolved
Hide resolved
833e231
to
29d2a9d
Compare
When a single `RedisConnection` is shared among multiple contexts (e.g. verticles), pipelining doesn't work correctly, because there is no coordination for concurrent access. This commit fixes that by making sure that all requests are performed from the same context on which the `NetSocket` was created. If the current context is different from the `NetSocket` context, the request is emitted on the correct context, which means no concurrent access, all requests are serialized.
29d2a9d
to
e97ca14
Compare
where is the extra promise allocated ? |
I rewrote to your suggestion with |
ah right out of order messages :-) |
When a single
RedisConnection
is shared among multiple contexts (e.g. verticles), pipelining doesn't work correctly, because there is no coordination for concurrent access. This commit fixes that by making sure that all requests are performed from the same context on which theNetSocket
was created. If the current context is different from theNetSocket
context, the request is emitted on the correct context, which means no concurrent access, all requests are serialized.Fixes #394