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 2022/04/07 02:49:24 UTC

[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #5367: [IOTDB-2727] data block manager impl

xingtanzjr commented on code in PR #5367:
URL: https://github.com/apache/iotdb/pull/5367#discussion_r844587804


##########
server/src/main/java/org/apache/iotdb/db/mpp/memory/MemoryPool.java:
##########
@@ -79,11 +147,35 @@ public synchronized void free(String queryId, long bytes) {
     } else {
       queryMemoryReservations.put(queryId, queryReservedBytes);
     }
-
     reservedBytes -= bytes;
+
+    if (memoryReservationFutures.isEmpty()) {
+      return;
+    }
+    Iterator<MemoryReservationFuture<Void>> iterator = memoryReservationFutures.iterator();
+    while (iterator.hasNext()) {
+      MemoryReservationFuture<Void> future = iterator.next();
+
+      if (future.isCancelled()) {
+        iterator.remove();
+        continue;
+      }
+
+      long bytesToReserve = future.getBytes();
+      if (maxBytes - reservedBytes < bytesToReserve
+          || maxBytesPerQuery - queryMemoryReservations.getOrDefault(future.getQueryId(), 0L)
+              < bytesToReserve) {
+        return;

Review Comment:
   We need to separate these two conditions here. If the maxBytes is not hit but the maxBytesPerQuery is hit, we need to continue to judge whether next future is satisfied or not because next future may belong to another query.
   
   ```
   if (maxBytes - reservedBytes < bytesToReserve) {
      return;
   }
   if (maxBytesPerQuery - queryMemoryReservations.getOrDefault(future.getQueryId(), 0L)
                 < bytesToReserve) {
      continue;
   }
   ```



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

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

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