You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2015/08/06 20:28:05 UTC

[jira] [Commented] (GEODE-146) Queries are not thread safe due to scopeId variable

    [ https://issues.apache.org/jira/browse/GEODE-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14660567#comment-14660567 ] 

ASF subversion and git services commented on GEODE-146:
-------------------------------------------------------

Commit 1a6a0ef53acfdc3931f48881b4b90907c16dc972 in incubator-geode's branch refs/heads/develop from Vito Gavrilov
[ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=1a6a0ef ]

Fix for GEODE-109

1) To fix this floating meta data problem for the redis list implementation, this meta data has been moved into the list region itself
2) Sorted set query failures are fixed by using fully qualified names and also depends on GEODE-146
3) Concurrent region creation/destruction logic completely changed to use dedicated locks for synchronization, fixed distributed deadlock
4) Added integration tests
5) Add javadocs where necessary

This closes #13


> 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<Integer, Portfolio> 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<Exception> exceptionsThrown = new LinkedList<Exception>();
>     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)