Return-Path: X-Original-To: apmail-geode-issues-archive@minotaur.apache.org Delivered-To: apmail-geode-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 69C611811B for ; Fri, 21 Aug 2015 14:37:49 +0000 (UTC) Received: (qmail 57002 invoked by uid 500); 21 Aug 2015 14:37:49 -0000 Delivered-To: apmail-geode-issues-archive@geode.apache.org Received: (qmail 56977 invoked by uid 500); 21 Aug 2015 14:37:49 -0000 Mailing-List: contact issues-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list issues@geode.incubator.apache.org Received: (qmail 56968 invoked by uid 99); 21 Aug 2015 14:37:49 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2015 14:37:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C08BD18266B for ; Fri, 21 Aug 2015 14:37:48 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.975 X-Spam-Level: X-Spam-Status: No, score=0.975 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id f70zRm80QzlL for ; Fri, 21 Aug 2015 14:37:47 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id BC0CC205B2 for ; Fri, 21 Aug 2015 14:37:46 +0000 (UTC) Received: (qmail 55737 invoked by uid 99); 21 Aug 2015 14:37:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2015 14:37:45 +0000 Date: Fri, 21 Aug 2015 14:37:45 +0000 (UTC) From: "Anthony Baker (JIRA)" To: issues@geode.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (GEODE-146) Queries are not thread safe due to scopeId variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GEODE-146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Anthony Baker closed GEODE-146. ------------------------------- Resolution: Fixed > Queries are not thread safe due to scopeId variable > --------------------------------------------------- > > Key: GEODE-146 > URL: https://issues.apache.org/jira/browse/GEODE-146 > Project: Geode > Issue Type: Bug > Components: querying > Reporter: Jason Huynh > Assignee: Jason Huynh > > Currently queries are not thread safe although they should be. This is due to the way the scopeId is stored in the CompiledSelect. The fix consists of storing the scopeId in the execution context. > public void testThreadSafetyOfCompiledSelectScopeId() throws Exception { > Cache cache = CacheUtils.getCache(); > RegionFactory rf = cache > .createRegionFactory(RegionShortcut.PARTITION); > Region r = rf.create("keyzset"); > for (int i = 0; i < 100; i++) { > r.put(i, new Portfolio(i)); > } > ScopeThreadingTestHook scopeIDTestHook = new ScopeThreadingTestHook(3); > DefaultQuery.testHook = scopeIDTestHook; > QueryService qs = cache.getQueryService(); > Query q = qs > .newQuery("SELECT DISTINCT * FROM /keyzset.keySet key WHERE key.id > 0 AND key.id <= 0 ORDER BY key asc LIMIT $3"); > Thread q1 = new Thread(new QueryRunnable(q, new Object[] { 10, 20, 10 })); > Thread q2 = new Thread(new QueryRunnable(q, new Object[] { 5, 10, 5 })); > Thread q3 = new Thread(new QueryRunnable(q, new Object[] { 2, 10, 8 })); > q1.start(); > q2.start(); > q3.start(); > q1.join(); > q2.join(); > q3.join(); > assertEquals("Exceptions were thrown due to DefaultQuery not being thread-safe", true, scopeIDTestHook.isOk()); > } > private class QueryRunnable implements Runnable { > private Query q; > private Object[] params; > public QueryRunnable(Query q, Object[] params) { > this.q = q; > this.params = params; > } > public void run() { > try { > q.execute(params); > } catch (Exception e) { > throw new TestException("exception occured while executing query", e); > } > } > } > public class ScopeThreadingTestHook implements DefaultQuery.TestHook { > private CyclicBarrier barrier; > private List exceptionsThrown = new LinkedList(); > public ScopeThreadingTestHook(int numThreads) { > barrier = new CyclicBarrier(numThreads); > } > @Override > public void doTestHook(int spot) { > this.doTestHook(spot + ""); > } > @Override > public void doTestHook(String spot) { > if (spot.equals("1")) { > try { > barrier.await(8, TimeUnit.SECONDS); > } catch (InterruptedException e) { > exceptionsThrown.add(e); > Thread.currentThread().interrupt(); > } catch (Exception e) { > exceptionsThrown.add(e); > } > } > } > public boolean isOk() { > return exceptionsThrown.size() == 0; > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)