Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 41147 invoked from network); 10 Jul 2010 06:06:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Jul 2010 06:06:23 -0000 Received: (qmail 69854 invoked by uid 500); 10 Jul 2010 06:06:23 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 69653 invoked by uid 500); 10 Jul 2010 06:06:21 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 69645 invoked by uid 99); 10 Jul 2010 06:06:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jul 2010 06:06:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jul 2010 06:06:16 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6A65tGP013035 for ; Sat, 10 Jul 2010 06:05:55 GMT Message-ID: <19884465.38071278741955266.JavaMail.jira@thor> Date: Sat, 10 Jul 2010 02:05:55 -0400 (EDT) From: "Rob Davies (JIRA)" To: dev@activemq.apache.org Subject: [jira] Commented: (AMQ-2820) Deadlock occur in the RegionBroker.java when remove stale connection In-Reply-To: <6445289.37841278699891814.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: ae95407df07c98740808b2ef9da0087c X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/AMQ-2820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=60567#action_60567 ] Rob Davies commented on AMQ-2820: --------------------------------- The thread would already have the lock on clientIdSet before calling removeConnection() - so not sure why you think there would be a deadlock - do you have a stacktrace ? > Deadlock occur in the RegionBroker.java when remove stale connection > -------------------------------------------------------------------- > > Key: AMQ-2820 > URL: https://issues.apache.org/activemq/browse/AMQ-2820 > Project: ActiveMQ > Issue Type: Bug > Components: Broker > Affects Versions: 5.0.0, 5.1.0, 5.2.0, 5.3.0, 5.3.1, 5.3.2 > Reporter: Suriyan > Priority: Minor > > {code:title=RegionBroker.java|borderStyle=solid} > 213 @Override > 214 public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception { > 215 String clientId = info.getClientId(); > 216 if (clientId == null) { > 217 throw new InvalidClientIDException("No clientID specified for connection request"); > 218 } > 219 synchronized (clientIdSet) { > 220 ConnectionContext oldContext = clientIdSet.get(clientId); > 221 if (oldContext != null) { > 222 if (context.isFaultTolerant() || context.isNetworkConnection()){ > 223 //remove the old connection > 224 try{ > 225 removeConnection(oldContext, info, new Exception("remove stale client")); > 226 }catch(Exception e){ > 227 LOG.warn("Failed to remove stale connection ",e); > 228 } > 229 }else{ > 230 throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " > 231 + oldContext.getConnection().getRemoteAddress()); > 232 } > 233 } else { > 234 clientIdSet.put(clientId, context); > 235 } > 236 } > 237 > 238 connections.add(context.getConnection()); > 239 } > 240 > 241 @Override > 242 public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception { > 243 String clientId = info.getClientId(); > 244 if (clientId == null) { > 245 throw new InvalidClientIDException("No clientID specified for connection disconnect request"); > 246 } > 247 synchronized (clientIdSet) { > 248 ConnectionContext oldValue = clientIdSet.get(clientId); > 249 // we may be removing the duplicate connection, not the first > 250 // connection to be created > 251 // so lets check that their connection IDs are the same > 252 if (oldValue == context) { > 253 if (isEqual(oldValue.getConnectionId(), info.getConnectionId())) { > 254 clientIdSet.remove(clientId); > 255 } > 256 } > 257 } > 258 connections.remove(context.getConnection()); > 259 } > {code} > In the removeConnection(...) method need to synchronized for clientIdSet object. Deadlock will occur when removeConnection(...) is called in the synchronized(clientIdSet) context from the addConnection(...) method (line 225). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.