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 8123318D2F for ; Fri, 19 Jun 2015 04:58:21 +0000 (UTC) Received: (qmail 91622 invoked by uid 500); 19 Jun 2015 04:58:21 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 91580 invoked by uid 500); 19 Jun 2015 04:58:21 -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 91568 invoked by uid 99); 19 Jun 2015 04:58:20 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2015 04:58:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 645C91A5D51 for ; Fri, 19 Jun 2015 04:58:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.25 X-Spam-Level: *** X-Spam-Status: No, score=3.25 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 7VUDL57j69CQ for ; Fri, 19 Jun 2015 04:58:05 +0000 (UTC) Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 3327928019 for ; Fri, 19 Jun 2015 04:58:04 +0000 (UTC) Received: by iecrd14 with SMTP id rd14so68220706iec.3 for ; Thu, 18 Jun 2015 21:58:03 -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=2CQ8lUYZ6JuNmo0bl8lfFdyQMVKgiLnGCYpwcWli52I=; b=MWRCjwVjyE3S3IevT9Pw+9dTwJgF2l7/b4jnfvDkUBVtF09JNgQ2dE/KCE5wsnYv9J acoXlfLKzhk8EkPevyUWWZ5JtDMbTbxX1/+vnEgKrjgfGyfKZazMChnLoaFGFvMQ4SAA V/6eJJvDa2gcLtP3fPJkq34dEs/3W6GPl7hdXVoo9Tsc5+XsD3fKINVYtWX8Mm6flzTa PBqhWyVkOx1oL0ofxFgeXQ8dwbtJyl3KoNOsq6UGwivz3cWV9BgJ6xDdH9TGXHTUIwOm fB9eHnX8J9dE663lPfqV3I1TtbPIMJXnJD3ZuFGjCE1yXSGuciXbX+MrFF8hEuw91w8m eLWw== X-Received: by 10.43.163.129 with SMTP id mo1mr9469335icc.61.1434689883128; Thu, 18 Jun 2015 21:58:03 -0700 (PDT) MIME-Version: 1.0 Sender: tbain98@gmail.com Received: by 10.50.251.141 with HTTP; Thu, 18 Jun 2015 21:57:43 -0700 (PDT) In-Reply-To: References: From: Tim Bain Date: Thu, 18 Jun 2015 22:57:43 -0600 X-Google-Sender-Auth: B-xgmxLwriRbRiEjjvb0RDmynKc Message-ID: Subject: Re: Potential threading bug in MemoryMessageStore. To: ActiveMQ Users Content-Type: multipart/alternative; boundary=001a11c30b4ed8cc1b0518d7c4f6 --001a11c30b4ed8cc1b0518d7c4f6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 b= ut the > thread reading it may have a cache copy of the data structure meaning it > 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 f= or 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 > > > --001a11c30b4ed8cc1b0518d7c4f6--