This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 3ff6145  [To rel/0.12] Fix when opening too many file handlers, too 
many warning logs will be printed (#4892)
3ff6145 is described below

commit 3ff6145ede62ab8f627f5cee83b58b8f01c99152
Author: Jackie Tien <[email protected]>
AuthorDate: Wed Jan 19 09:52:13 2022 +0800

    [To rel/0.12] Fix when opening too many file handlers, too many warning 
logs will be printed (#4892)
---
 .../apache/iotdb/db/query/control/FileReaderManager.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java 
b/server/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
index 0046bf0..9badbf9 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
@@ -46,6 +46,12 @@ public class FileReaderManager {
   private static final int MAX_CACHED_FILE_SIZE = 30000;
 
   /**
+   * When number of file streams reached MAX_CACHED_FILE_SIZE, then we will 
print a warning log each
+   * PRINT_INTERVAL
+   */
+  private static final int PRINT_INTERVAL = 10000;
+
+  /**
    * the key of closedFileReaderMap is the file path and the value of 
closedFileReaderMap is the
    * corresponding reader.
    */
@@ -108,12 +114,13 @@ public class FileReaderManager {
     Map<String, TsFileSequenceReader> readerMap =
         !isClosed ? unclosedFileReaderMap : closedFileReaderMap;
     if (!readerMap.containsKey(filePath)) {
-
-      if (readerMap.size() >= MAX_CACHED_FILE_SIZE) {
+      int currentOpenedReaderCount = readerMap.size();
+      if (currentOpenedReaderCount >= MAX_CACHED_FILE_SIZE
+          && (currentOpenedReaderCount % PRINT_INTERVAL == 0)) {
         logger.warn("Query has opened {} files !", readerMap.size());
       }
 
-      TsFileSequenceReader tsFileReader = null;
+      TsFileSequenceReader tsFileReader;
       // check if the file is old version
       if (!isClosed) {
         tsFileReader = new UnClosedTsFileReader(filePath);

Reply via email to