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

Don't apply partition response coming from old connection #14793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -118,8 +118,8 @@ public void onListenerRegister() {

private void waitForPartitionsFetchedOnce() {
while (partitionCount == 0 && client.getConnectionManager().isAlive()) {
Connection ownerConnection = this.ownerConnection;
if (ownerConnection == null) {
Connection currentOwnerConnection = this.ownerConnection;
if (currentOwnerConnection == null) {
sleepBeforeNextTry();
continue;
}
Expand All @@ -132,11 +132,20 @@ private void waitForPartitionsFetchedOnce() {
// invocation should go to owner connection because the listener is added to owner connection
// and partition state version should be fetched from one member to keep it consistent
ClientInvocationFuture future =
new ClientInvocation(client, requestMessage, null, ownerConnection).invokeUrgent();
new ClientInvocation(client, requestMessage, null, currentOwnerConnection).invokeUrgent();
try {
ClientMessage responseMessage = future.get();
ClientGetPartitionsCodec.ResponseParameters response =
ClientGetPartitionsCodec.decodeResponse(responseMessage);
Connection connection = responseMessage.getConnection();
if (!currentOwnerConnection.equals(ownerConnection)) {
if (logger.isFinestEnabled()) {
logger.finest(" We will not apply the response, since response come from an old connection " + connection
+ ". Current connection " + this.ownerConnection + " state version:"
+ (response.partitionStateVersionExist ? response.partitionStateVersion : "NotAvailable"));
}
continue;
}
processPartitionResponse(response.partitions,
response.partitionStateVersion, response.partitionStateVersionExist);
} catch (Exception e) {
Expand Down