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