From dev-return-23027-apmail-activemq-dev-archive=activemq.apache.org@activemq.apache.org Wed Nov 03 22:58:52 2010 Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 47632 invoked from network); 3 Nov 2010 22:58:52 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Nov 2010 22:58:52 -0000 Received: (qmail 34392 invoked by uid 500); 3 Nov 2010 22:59:23 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 34359 invoked by uid 500); 3 Nov 2010 22:59:23 -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 34350 invoked by uid 99); 3 Nov 2010 22:59:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Nov 2010 22:59:23 +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; Wed, 03 Nov 2010 22:59:21 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id oA3Mx08M024729 for ; Wed, 3 Nov 2010 22:59:00 GMT Message-ID: <24780854.5731288825140079.JavaMail.jira@thor> Date: Wed, 3 Nov 2010 18:59:00 -0400 (EDT) From: "Stirling Chow (JIRA)" To: dev@activemq.apache.org Subject: [jira] Updated: (AMQ-3014) DemandForwardingBridgeSupport can send BrokerInfo to remote transport before local broker ID is known. In-Reply-To: <16832432.5721288825020049.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-3014?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Stirling Chow updated AMQ-3014: ------------------------------- Attachment: patch.txt Patch of DemandForwardingBridgeSupport, which waits until the local Broker's ID is known before transmitting the BrokerInfo to the remote transport. > DemandForwardingBridgeSupport can send BrokerInfo to remote transport before local broker ID is known. > ------------------------------------------------------------------------------------------------------ > > Key: AMQ-3014 > URL: https://issues.apache.org/activemq/browse/AMQ-3014 > Project: ActiveMQ > Issue Type: Bug > Components: Broker, Transport > Affects Versions: 5.4.1 > Reporter: Stirling Chow > Attachments: patch.txt > > > Symptom > ======== > We have a production system that involves a set of Brokers connected in a demand-forwarding Network-of-Brokers using HTTP-based bridges. Each Broker periodically scans its list of peer brokers by iterating over RegionBroker.getPeerBrokerInfos: > public synchronized BrokerInfo[] getPeerBrokerInfos() { > BrokerInfo[] result = new BrokerInfo[brokerInfos.size()]; > result = brokerInfos.toArray(result); > return result; > } > This scanning code assumes that BrokerInfo.getBrokerId() is always non-null (since every broker should have an ID). However, we periodically noticed that BrokerInfo.getBrokerId() returned a NULL value, which was very unexpected. > Cause > ====== > We analyzed the DemandForwardingBridgeSupport and noticed that when the remote bridge/transport is started, it sends the local Broker's ID: > protected void startRemoteBridge() throws Exception { > ... > brokerInfo.setBrokerId(this.localBrokerId); > remoteBroker.oneway(brokerInfo); > } > The local Broker's ID is not initially known until it is received from the local transport and processed by DemandForwardingBridge.serviceLocalBrokerInfo(...): > protected void serviceLocalBrokerInfo(Command command) throws InterruptedException { > synchronized (brokerInfoMutex) { > localBrokerId = ((BrokerInfo)command).getBrokerId(); > localBrokerPath[0] = localBrokerId; > localBrokerIdKnownLatch.countDown(); > The local Broker's ID is dispatched asynchronously when the local transport is started, as seen in TransportConnection.start(): > public void start() throws Exception { > starting = true; > try { > synchronized (this) { > if (taskRunnerFactory != null) { > taskRunner = taskRunnerFactory.createTaskRunner(this, "ActiveMQ Connection Dispatcher: " > + getRemoteAddress()); > } else { > taskRunner = null; > } > transport.start(); > active = true; > dispatchAsync(connector.getBrokerInfo()); > Because of the asynchronous dispatch, the remote bridge may be started before the local Broker's ID is known. This would be particularly evident when the local broker is under load processing a lot of tasks. > We've attached a unit test that demonstrates how a slow asynchronous dispatch on the local transport can cause the remote transport to transmit a null BrokerId. > Solution > ====== > DemandForwardingBridgeSupport already contains a localBrokerIdKnownLatch, so starting the remote transport should wait for this latch before accessing the local Broker's ID (see patch). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.