diff --git a/seaweed-volume/src/server/grpc_server.rs b/seaweed-volume/src/server/grpc_server.rs index 46daeff0e..97882ba9b 100644 --- a/seaweed-volume/src/server/grpc_server.rs +++ b/seaweed-volume/src/server/grpc_server.rs @@ -515,7 +515,7 @@ impl VolumeServer for VolumeGrpcService { collection: vol.collection.clone(), replication: vol.super_block.replica_placement.to_string(), ttl: vol.super_block.ttl.to_string(), - tail_offset: vol.content_size(), + tail_offset: vol.dat_file_size().unwrap_or(0), compact_revision: vol.super_block.compaction_revision as u32, idx_file_size: vol.idx_file_size(), version: vol.version().0 as u32, diff --git a/test/volume_server/grpc/copy_sync_test.go b/test/volume_server/grpc/copy_sync_test.go index 9678efe4b..810395fb6 100644 --- a/test/volume_server/grpc/copy_sync_test.go +++ b/test/volume_server/grpc/copy_sync_test.go @@ -22,8 +22,15 @@ func TestVolumeSyncStatusAndReadVolumeFileStatus(t *testing.T) { conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress()) defer conn.Close() + httpClient := framework.NewHTTPClient() const volumeID = uint32(41) framework.AllocateVolume(t, grpcClient, volumeID, "") + fid := framework.NewFileID(volumeID, 1, 0x11112222) + uploadResp := framework.UploadBytes(t, httpClient, clusterHarness.VolumeAdminURL(), fid, []byte("sync-status-payload")) + _ = framework.ReadAllAndClose(t, uploadResp) + if uploadResp.StatusCode != http.StatusCreated { + t.Fatalf("upload expected 201, got %d", uploadResp.StatusCode) + } ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -46,6 +53,12 @@ func TestVolumeSyncStatusAndReadVolumeFileStatus(t *testing.T) { if statusResp.GetVersion() == 0 { t.Fatalf("ReadVolumeFileStatus expected non-zero version") } + if syncResp.GetTailOffset() == 0 { + t.Fatalf("VolumeSyncStatus expected non-zero tail offset after upload") + } + if syncResp.GetTailOffset() != statusResp.GetDatFileSize() { + t.Fatalf("VolumeSyncStatus tail offset mismatch: got %d want %d", syncResp.GetTailOffset(), statusResp.GetDatFileSize()) + } } func TestCopyAndStreamMethodsMissingVolumePaths(t *testing.T) {