Skip to content

Commit

Permalink
Fix calculation of remaining bytes while sending snapshot to client..
Browse files Browse the repository at this point in the history
Signed-off-by: ishan16696 <[email protected]>
  • Loading branch information
ishan16696 committed Dec 30, 2024
1 parent 6c4e7df commit b256f52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/etcdserver/api/v3rpc/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance

sent := int64(0)
total := snap.Size()
totalByteToSend := total + int64(h.Size())
size := humanize.Bytes(uint64(total))

start := time.Now()
ms.lg.Info("sending database snapshot to client",
zap.Int64("total-bytes", total),
zap.String("size", size),
zap.Int64("total-bytes-to-send", totalByteToSend),
zap.String("database-size", size),
zap.String("storage-version", storageVersion),
)
for total-sent > 0 {
Expand All @@ -178,7 +179,7 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
// No, the client will still receive non-nil response
// until server closes the stream with EOF
resp := &pb.SnapshotResponse{
RemainingBytes: uint64(total - sent),
RemainingBytes: uint64(totalByteToSend - sent),
Blob: buf[:n],
Version: storageVersion,
}
Expand All @@ -202,8 +203,8 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
}

ms.lg.Info("successfully sent database snapshot to client",
zap.Int64("total-bytes", total),
zap.String("size", size),
zap.Int64("total-bytes-sent", totalByteToSend),
zap.String("database-size", size),
zap.Duration("took", time.Since(start)),
zap.String("storage-version", storageVersion),
)
Expand Down

0 comments on commit b256f52

Please sign in to comment.