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/05 06:29:10 UTC

[GitHub] [iotdb] mychaow commented on a change in pull request #2635: [IOTDB-1148]fix the client leak of client pool&use remote schema cache when check timeseries exist or not

mychaow commented on a change in pull request #2635:
URL: https://github.com/apache/iotdb/pull/2635#discussion_r570747318



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/query/reader/RemoteSeriesReaderByTimestamp.java
##########
@@ -86,20 +86,23 @@ private ByteBuffer fetchResultAsync(long timestamp) throws IOException {
   }
 
   private ByteBuffer fetchResultSync(long timestamp) throws IOException {
+    SyncDataClient curSyncClient = null;
     try {
-      SyncDataClient curSyncClient = sourceInfo
+      curSyncClient = sourceInfo
           .getCurSyncClient(RaftServer.getReadOperationTimeoutMS());
-      ByteBuffer buffer = curSyncClient
+      return curSyncClient
           .fetchSingleSeriesByTimestamp(sourceInfo.getHeader(),
               sourceInfo.getReaderId(), timestamp);
-      curSyncClient.putBack();
-      return buffer;
     } catch (TException e) {
       //try other node
       if (!sourceInfo.switchNode(true, timestamp)) {
         return null;
       }
       return fetchResultSync(timestamp);
+    } finally {
+      if (curSyncClient != null) {

Review comment:
         ClientUtils.putBackSyncClient(client)   is better.

##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/query/reader/RemoteSimpleSeriesReader.java
##########
@@ -136,20 +136,23 @@ private ByteBuffer fetchResultAsync() throws IOException {
   }
 
   private ByteBuffer fetchResultSync() throws IOException {
+    SyncDataClient curSyncClient = null;
     try {
-      SyncDataClient curSyncClient = sourceInfo
+      curSyncClient = sourceInfo
           .getCurSyncClient(RaftServer.getReadOperationTimeoutMS());
-      ByteBuffer buffer = curSyncClient
+      return curSyncClient
           .fetchSingleSeries(sourceInfo.getHeader(),
               sourceInfo.getReaderId());
-      curSyncClient.putBack();
-      return buffer;
     } catch (TException e) {
       //try other node
       if (!sourceInfo.switchNode(false, lastTimestamp)) {
         return null;
       }
       return fetchResultSync();
+    } finally {
+      if (curSyncClient != null) {
+        curSyncClient.putBack();

Review comment:
       same.




----------------------------------------------------------------
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