ARTEMIS-1506 Synchronization issue during failover in ClientSessionImpl

The temporary deadlock is avoided by removing 'synchronized' from
ClientSessionImpl::getCredits method. As the method uses only
a producerCreditManger, only this object is guarded against
the parallel access.
This commit is contained in:
Erich Duda 2017-11-03 16:19:54 +01:00 committed by Clebert Suconic
parent 93f4e41beb
commit 5cc8faedd8
1 changed files with 21 additions and 10 deletions

View File

@ -1156,7 +1156,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
try {
closeChildren();
synchronized (this) {
synchronized (producerCreditManager) {
producerCreditManager.close();
}
inClose = true;
@ -1177,7 +1177,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return;
}
synchronized (producerCreditManager) {
producerCreditManager.close();
}
cleanUpChildren();
@ -1282,7 +1284,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
if (resetCreditManager) {
synchronized (producerCreditManager) {
producerCreditManager.reset();
}
// Also need to send more credits for consumers, otherwise the system could hand with the server
// not having any credits to send
@ -1343,26 +1347,33 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
@Override
public synchronized ClientProducerCredits getCredits(final SimpleString address, final boolean anon) {
public ClientProducerCredits getCredits(final SimpleString address, final boolean anon) {
synchronized (producerCreditManager) {
ClientProducerCredits credits = producerCreditManager.getCredits(address, anon, sessionContext);
return credits;
}
}
@Override
public void returnCredits(final SimpleString address) {
synchronized (producerCreditManager) {
producerCreditManager.returnCredits(address);
}
}
@Override
public void handleReceiveProducerCredits(final SimpleString address, final int credits) {
synchronized (producerCreditManager) {
producerCreditManager.receiveCredits(address, credits);
}
}
@Override
public void handleReceiveProducerFailCredits(final SimpleString address, int credits) {
synchronized (producerCreditManager) {
producerCreditManager.receiveFailCredits(address, credits);
}
}
@Override
public ClientProducerCreditManager getProducerCreditManager() {