mychaow commented on a change in pull request #1561:
URL: https://github.com/apache/incubator-iotdb/pull/1561#discussion_r460621316



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/log/catchup/LogCatchUpTask.java
##########
@@ -178,11 +181,21 @@ void doLogCatchUpInBatch() throws TException, 
InterruptedException {
     }
 
     List<ByteBuffer> logList = new ArrayList<>();
-    for (int i = 0; i < logs.size() && !abort; i += LOG_NUM_IN_BATCH) {
+    for (int i = 0; i < logs.size() && !abort;) {
       logList.clear();
-      for (int j = i; j < i + LOG_NUM_IN_BATCH && j < logs.size(); j++) {
-        logList.add(logs.get(j).serialize());
+      long totalLogSize = 0;
+      int newStart = i;
+      for (int curNum = 0; curNum < LOG_NUM_IN_BATCH && i < logs.size(); i++, 
curNum++) {
+        ByteBuffer logData = logs.get(i).serialize();
+        totalLogSize += logData.array().length;
+        // we should send logs who's size is smaller than the max frame size 
of thrift
+        // left 200 byte for other fields of AppendEntriesRequest
+        if (totalLogSize > 
IoTDBDescriptor.getInstance().getConfig().getThriftMaxFrameSize() - 
LEFT_SIZE_IN_REQUEST) {
+          break;
+        }

Review comment:
       Not break a request into several frames. If a request is too large, it 
will be failed. A frame hold a full request data.  
https://blog.csdn.net/duyuanhai/article/details/53332981, 
https://andrewpqc.github.io/2019/02/24/thrift/




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to