Browse Source

debug: add detailed chunk size logging to diagnose EOF issue

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.
pull/7526/head
chrislu 2 months ago
parent
commit
551883694b
  1. 7
      other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
  2. 8
      other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java

7
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<FilerProto.FileChunk> chunksList) {

8
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<FilerProto.FileChunk> 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(

Loading…
Cancel
Save