From 551883694bfd9d82c26b21ae0aa4c984ef8b91bc Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 22 Nov 2025 23:52:34 -0800 Subject: [PATCH] debug: add detailed chunk size logging to diagnose EOF issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added INFO-level logging to track: 1. Every chunk write: offset, size, etag, target URL 2. Metadata update: total chunks count and calculated file size 3. File size calculation: breakdown of chunks size vs attr size This will reveal: - If chunks are being written with correct sizes - If metadata file size matches sum of chunks - If there's a mismatch causing the '78 bytes left' EOF Example output expected: ✓ Wrote chunk to http://volume:8080/3,xxx at offset 0 size 1048576 bytes ✓ Wrote chunk to http://volume:8080/3,yyy at offset 1048576 size 524288 bytes ✓ Writing metadata with 2 chunks, total size: 1572864 bytes Calculated file size: 1572864 (chunks: 1572864, attr: 0, #chunks: 2) If we see size=X in write but size=X-78 in read, that's the smoking gun. --- .../src/main/java/seaweedfs/client/SeaweedRead.java | 7 ++++++- .../src/main/java/seaweedfs/client/SeaweedWrite.java | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java index cac85d186..dbade3408 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java @@ -239,7 +239,12 @@ public class SeaweedRead { } public static long fileSize(FilerProto.Entry entry) { - return Math.max(totalSize(entry.getChunksList()), entry.getAttributes().getFileSize()); + long chunksSize = totalSize(entry.getChunksList()); + long attrSize = entry.getAttributes().getFileSize(); + long finalSize = Math.max(chunksSize, attrSize); + LOG.info("Calculated file size: {} (chunks: {}, attr: {}, #chunks: {})", + finalSize, chunksSize, attrSize, entry.getChunksCount()); + return finalSize; } public static long totalSize(List chunksList) { diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java index 5d4375d0f..d83245363 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java @@ -125,7 +125,7 @@ public class SeaweedWrite { String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey); - LOG.debug("write file chunk {} size {}", targetUrl, bytesLength); + LOG.info("✓ Wrote chunk to {} at offset {} size {} bytes, etag: {}", targetUrl, offset, bytesLength, etag); return FilerProto.FileChunk.newBuilder() .setFileId(fileId) @@ -143,6 +143,12 @@ public class SeaweedWrite { synchronized (entry) { List chunks = FileChunkManifest.maybeManifestize(filerClient, entry.getChunksList(), parentDirectory); + long totalSize = 0; + for (FilerProto.FileChunk chunk : chunks) { + totalSize = Math.max(totalSize, chunk.getOffset() + chunk.getSize()); + } + LOG.info("✓ Writing metadata to {} with {} chunks, total size: {} bytes", + parentDirectory + "/" + entry.getName(), chunks.size(), totalSize); entry.clearChunks(); entry.addAllChunks(chunks); filerClient.getBlockingStub().createEntry(