Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 219EE18B66 for ; Sun, 21 Jun 2015 02:43:51 +0000 (UTC) Received: (qmail 49654 invoked by uid 500); 21 Jun 2015 02:43:50 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 49607 invoked by uid 500); 21 Jun 2015 02:43:50 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 49595 invoked by uid 99); 21 Jun 2015 02:43:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jun 2015 02:43:50 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of burtonator2011@gmail.com designates 209.85.218.48 as permitted sender) Received: from [209.85.218.48] (HELO mail-oi0-f48.google.com) (209.85.218.48) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jun 2015 02:41:36 +0000 Received: by oiyy130 with SMTP id y130so85517279oiy.0 for ; Sat, 20 Jun 2015 19:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=nRYvh6jan1tbk4/HHxh7HKN3Ybu+32FB0MFslw4oJPA=; b=GyProTtzPsBgX6xFolJ8USWQHfh8QUezG5xdMmVKvEe5vJrXRomLGlOgkRs00eWsc0 8y2YZjzz3tw1VJ6X1YYIY9SWV6tiqNZ1HpQjT7zB2d8hW9sZq8h6GtHrtMFqUdOEpCcs XAt3puwcngAtvNMg9RYtH8W51ciLl2dCw05M0BzW9pj803bwm001NHuppS09s+IHqX9o UOkiH1xdSj6QQzn5huNdtIHvl7vrMP6UtKjprVBVaS3TAoioAj1brJ61db2VJSb1AlrL 7UX2w4AHlQPV20x+/xoVHkK5jqWkeWWfDAq4yh0g+Z4oZh4cHgtY8DPdFug8hsucdVfV JyLw== X-Received: by 10.202.77.76 with SMTP id a73mr6131748oib.80.1434854603862; Sat, 20 Jun 2015 19:43:23 -0700 (PDT) MIME-Version: 1.0 Sender: burtonator2011@gmail.com Received: by 10.183.6.233 with HTTP; Sat, 20 Jun 2015 19:43:04 -0700 (PDT) In-Reply-To: References: From: Kevin Burton Date: Sat, 20 Jun 2015 19:43:04 -0700 X-Google-Sender-Auth: KEk7llIpXu-05_ve1jSPFrICr2o Message-ID: Subject: Re: Potential threading bug in MemoryMessageStore. To: users@activemq.apache.org Content-Type: multipart/alternative; boundary=001a1134fa5cf7b7890518fe1edb X-Virus-Checked: Checked by ClamAV on apache.org --001a1134fa5cf7b7890518fe1edb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I didn=E2=80=99t.. it=E2=80=99s a race so if it=E2=80=99s happening is prob= ably happening not that often . Maybe a test could be created to try to introduce the race. On Thu, Jun 18, 2015 at 9:57 PM, Tim Bain wrote: > Did you look at this any further? Looking at the code, it looks like the > call will be protected without explicit synchronization by the intrinsic > lock on the synchronizedMap (and I think that some other methods such as > delete() and addMessage() that just call a method on the synchronizedMap > could have their synchronized blocks removed), though I might be looking = at > that wrong. > > Tim > > On Mon, Apr 6, 2015 at 1:58 PM, Kevin Burton wrote: > > > Pretty sure getMessage() in MemoryMessageStore has a bug. > > > > All access to messageTable is synchronized. this method is not. This > > means that there=E2=80=99s a race where a message can go into the queue= but the > > thread reading it may have a cache copy of the data structure meaning i= t > > would get a cache miss > > > > Also, it looks like =E2=80=9CaddMessage=E2=80=9D is doubly synchronized= . > > > > public Message getMessage(MessageId identity) throws IOException { > > return messageTable.get(identity); > > } > > > > =E2=80=A6 I=E2=80=99m going to migrate to using a PriorityBlockingQueue= for this and > remove > > all the synchronization and will try to submit a patch. Also I think > > PriorityBlockingQueue will lower memory usage by 40% > > > > > > -- > > > > Founder/CEO Spinn3r.com > > Location: *San Francisco, CA* > > blog: http://burtonator.wordpress.com > > =E2=80=A6 or check out my Google+ profile > > > > > > > --=20 Founder/CEO Spinn3r.com Location: *San Francisco, CA* blog: http://burtonator.wordpress.com =E2=80=A6 or check out my Google+ profile --001a1134fa5cf7b7890518fe1edb--