jt2594838 commented on code in PR #19190:
URL: https://github.com/apache/iotdb/pull/19190#discussion_r4520486407


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/SchemaPage.java:
##########
@@ -106,7 +107,15 @@ public void syncPageBuffer() {
   @Override
   public void flushPageToChannel(FileChannel channel) throws IOException {
     this.pageBuffer.clear();
-    channel.write(pageBuffer, SchemaFile.getPageAddress(pageIndex));
+    long position = SchemaFile.getPageAddress(pageIndex);
+    while (pageBuffer.hasRemaining()) {
+      int written = channel.write(pageBuffer, position);
+      if (written <= 0) {
+        throw new IOException(
+            
DataNodeSchemaMessages.EXCEPTION_SCHEMA_PAGE_WRITE_MADE_NO_PROGRESS_E79C13A1);
+      }
+      position += written;
+    }

Review Comment:
   May add an `int static writeFully(FileChannel, ByteBuffer, long)` to some 
util, and add a test based on ArchUnit to forbid the raw use of `channel.write` 
in other places.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to