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


##########
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:
   Applied in fa9a85ab732977e989ab4764550b2282e7b48a5c.
   
   Added `IOUtils.writeFully(FileChannel, ByteBuffer, long)`, returning the 
number of bytes written, plus a sequential overload for append writes. Schema 
pages, headers, and the recovery-log commit marker now use these helpers. Both 
helpers complete short writes, fail immediately on zero progress, and propagate 
the original I/O exception.
   
   Added an ArchUnit rule that rejects direct calls to all four 
`FileChannel.write` overloads in the schema-file production package and its 
subpackages. Positive and negative fixtures verify the rule. The guard is 
scoped to this subsystem; migrating existing writers in other subsystems can be 
handled separately.
   
   Validation: all 40 focused unit tests passed, including the helper boundary 
tests and ArchUnit tests. English and Chinese compilation passed for the 28 
relevant reactor modules. Full-repository compilation remains unverified 
because the isolated dependency downloads exceeded the verification budget.



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