You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/02/08 15:33:34 UTC

[GitHub] [iotdb] yuqi1129 opened a new issue #2661: Statistics value in SyncClientPool/AsyncClientPool have concurrency problem

yuqi1129 opened a new issue #2661:
URL: https://github.com/apache/iotdb/issues/2661


   **Describe the bug**
   Though field nodeClientNumMap and clientCaches is protected by object lock, but after wake up from monitor lock , this two field should also guarded by lock or concurrency problem will occur
   
   **To Reproduce**
   Steps to reproduce the behavior:
   See code:
   DataClientProviderTest
   ```java
   @Test
     public void testSync() throws IOException, InterruptedException {
       Node node = new ClusterNode();
       node.setDataPort(9003).setIp("localhost");
       ServerSocket serverSocket = new ServerSocket(node.getDataPort());
       Thread listenThread = new Thread(() -> {
         while (!Thread.interrupted()) {
           try {
             serverSocket.accept();
           } catch (IOException e) {
             return;
           }
         }
       });
       listenThread.start();
   
       try {
         boolean useAsyncServer = ClusterDescriptor.getInstance().getConfig().isUseAsyncServer();
         ClusterDescriptor.getInstance().getConfig().setUseAsyncServer(false);
         ClusterDescriptor.getInstance().getConfig().setMaxClientPerNodePerMember(2);
         DataClientProvider provider = new DataClientProvider(new Factory());
         SyncDataClient client = null;
         try {
           client = provider.getSyncDataClient(node, 100);
         } catch (TException e) {
           Assert.fail(e.getMessage());
         }
         assertNotNull(client);
   
         //now try to test multi thread
         ExecutorService service = Executors.newFixedThreadPool(10);
         for (int i = 0; i < 4; i++) {
           service.submit(() -> provider.getSyncDataClient(node, 100));
         }
   
         //wait time should be great then 5000ms
         Thread.currentThread().sleep(10000);
         int totalNumber = provider.getDataSyncClientPool().getNodeClientNumMap().get(node);
         assertEquals(5, totalNumber);
   
         for (int i = 0; i < 4; i++) {
           service.submit(() -> provider.getSyncDataClient(node, 100));
         }
   
         Thread.currentThread().sleep(1000);
         //return one client to pool
         provider.getDataSyncClientPool().putClient(node, client);
         //wait all finish
         Thread.currentThread().sleep(10000);
         totalNumber = provider.getDataSyncClientPool().getNodeClientNumMap().get(node);
   
         //5 + 4 - 1
         assertEquals(8, totalNumber);
   
         ClusterDescriptor.getInstance().getConfig().setUseAsyncServer(useAsyncServer);
       } catch (Exception e) {
         Assert.fail(e.getMessage());
       } finally {
         serverSocket.close();
         listenThread.interrupt();
         listenThread.join();
       }
   ```
   
   The test will failed
   
   **Expected behavior**
   A clear and concise description of what you expected to happen.
   
   **Screenshots**
   If applicable, add screenshots to help explain your problem.
   ![image](https://user-images.githubusercontent.com/15794564/107240652-1ca8d580-6a65-11eb-9178-3f7c4ed63e56.png)
   
   ![image](https://user-images.githubusercontent.com/15794564/107241503-00596880-6a66-11eb-9fe1-253fa2953c2e.png)
   
   
   
   **Desktop (please complete the following information):**
    - OS: [e.g. iOS]
    - Browser [e.g. chrome, safari]
    - Version [e.g. 22]
   
   **Additional context**
   Add any other context about the problem here.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] HTHou closed issue #2661: Statistics value in SyncClientPool/AsyncClientPool have concurrency problem

Posted by GitBox <gi...@apache.org>.
HTHou closed issue #2661:
URL: https://github.com/apache/iotdb/issues/2661


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org