ARTEMIS-1368 Artemis gets to state when it doesn't respond to producer

There is a leak on replication tokens in the moment when a backup is
shutdowned or killed and the ReplicationManager is stopped. If there
are some tasks (holding replication tokens) in the executor, these
tokens are simply ignored and replicationDone method isn't called on
them. Because of this, some tasks in OperationContextImpl cannot be
finished.
This commit is contained in:
Erich Duda 2017-08-22 21:48:19 +02:00
parent cfdd9fb5bc
commit d6cbc0aa88
1 changed files with 13 additions and 21 deletions

View File

@ -350,34 +350,26 @@ public final class ReplicationManager implements ActiveMQComponent {
}
private OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) {
if (!enabled)
if (!enabled) {
packet.release();
return null;
boolean runItNow = false;
}
final OperationContext repliToken = OperationContextImpl.getContext(executorFactory);
if (lineUp) {
repliToken.replicationLineUp();
}
if (enabled) {
replicationStream.execute(() -> {
if (enabled) {
pendingTokens.add(repliToken);
flowControl(packet.expectedEncodeSize());
replicatingChannel.send(packet);
}
});
} else {
// Already replicating channel failed, so just play the action now
runItNow = true;
packet.release();
}
// Execute outside lock
if (runItNow) {
repliToken.replicationDone();
}
replicationStream.execute(() -> {
if (enabled) {
pendingTokens.add(repliToken);
flowControl(packet.expectedEncodeSize());
replicatingChannel.send(packet);
} else {
packet.release();
repliToken.replicationDone();
}
});
return repliToken;
}