mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
12126: snapshot: corrupted in Embedded server (#12129)
This commit is contained in:
parent
26b89fd418
commit
51de68ddac
@ -117,11 +117,6 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
|
|||||||
// used for integrity checks during snapshot restore operation
|
// used for integrity checks during snapshot restore operation
|
||||||
h := sha256.New()
|
h := sha256.New()
|
||||||
|
|
||||||
// buffer just holds read bytes from stream
|
|
||||||
// response size is multiple of OS page size, fetched in boltdb
|
|
||||||
// e.g. 4*1024
|
|
||||||
buf := make([]byte, snapshotSendBufferSize)
|
|
||||||
|
|
||||||
sent := int64(0)
|
sent := int64(0)
|
||||||
total := snap.Size()
|
total := snap.Size()
|
||||||
size := humanize.Bytes(uint64(total))
|
size := humanize.Bytes(uint64(total))
|
||||||
@ -132,6 +127,13 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
|
|||||||
zap.String("size", size),
|
zap.String("size", size),
|
||||||
)
|
)
|
||||||
for total-sent > 0 {
|
for total-sent > 0 {
|
||||||
|
// buffer just holds read bytes from stream
|
||||||
|
// response size is multiple of OS page size, fetched in boltdb
|
||||||
|
// e.g. 4*1024
|
||||||
|
// NOTE: srv.Send does not wait until the message is received by the client.
|
||||||
|
// Therefore the buffer can not be safely reused between Send operations
|
||||||
|
buf := make([]byte, snapshotSendBufferSize)
|
||||||
|
|
||||||
n, err := io.ReadFull(pr, buf)
|
n, err := io.ReadFull(pr, buf)
|
||||||
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
|
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
|
||||||
return togRPCError(err)
|
return togRPCError(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user