Browse Source

volume: atomic copying file, adds version and stopOffset

pull/934/head
Chris Lu 6 years ago
parent
commit
3b3651dea3
  1. 4
      weed/command/backup.go
  2. 3
      weed/pb/volume_server.proto
  3. 197
      weed/pb/volume_server_pb/volume_server.pb.go
  4. 31
      weed/server/volume_grpc_copy.go
  5. 2
      weed/storage/store.go
  6. 2
      weed/storage/volume.go
  7. 2
      weed/storage/volume_backup.go
  8. 6
      weed/storage/volume_super_block.go
  9. 8
      weed/storage/volume_vacuum.go

4
weed/command/backup.go

@ -90,7 +90,7 @@ func runBackup(cmd *Command, args []string) bool {
return true
}
if v.SuperBlock.CompactRevision < uint16(stats.CompactRevision) {
if v.SuperBlock.CompactionRevision < uint16(stats.CompactRevision) {
if err = v.Compact(0); err != nil {
fmt.Printf("Compact Volume before synchronizing %v\n", err)
return true
@ -99,7 +99,7 @@ func runBackup(cmd *Command, args []string) bool {
fmt.Printf("Commit Compact before synchronizing %v\n", err)
return true
}
v.SuperBlock.CompactRevision = uint16(stats.CompactRevision)
v.SuperBlock.CompactionRevision = uint16(stats.CompactRevision)
v.DataFile().WriteAt(v.SuperBlock.Bytes(), 0)
}

3
weed/pb/volume_server.proto

@ -162,6 +162,8 @@ message CopyFileRequest {
uint32 volume_id = 1;
bool is_idx_file = 2;
bool is_dat_file = 3;
uint32 compaction_revision = 4;
uint64 stop_offset = 5;
}
message CopyFileResponse {
bytes file_content = 1;
@ -188,6 +190,7 @@ message ReadVolumeFileStatusResponse {
uint64 dat_file_timestamp_seconds = 4;
uint64 dat_file_size = 5;
uint64 file_count = 6;
uint32 compaction_revision = 7;
}
message DiskStatus {

197
weed/pb/volume_server_pb/volume_server.pb.go

@ -600,6 +600,8 @@ type CopyFileRequest struct {
VolumeId uint32 `protobuf:"varint,1,opt,name=volume_id,json=volumeId" json:"volume_id,omitempty"`
IsIdxFile bool `protobuf:"varint,2,opt,name=is_idx_file,json=isIdxFile" json:"is_idx_file,omitempty"`
IsDatFile bool `protobuf:"varint,3,opt,name=is_dat_file,json=isDatFile" json:"is_dat_file,omitempty"`
CompactionRevision uint32 `protobuf:"varint,4,opt,name=compaction_revision,json=compactionRevision" json:"compaction_revision,omitempty"`
StopOffset uint64 `protobuf:"varint,5,opt,name=stop_offset,json=stopOffset" json:"stop_offset,omitempty"`
}
func (m *CopyFileRequest) Reset() { *m = CopyFileRequest{} }
@ -628,6 +630,20 @@ func (m *CopyFileRequest) GetIsDatFile() bool {
return false
}
func (m *CopyFileRequest) GetCompactionRevision() uint32 {
if m != nil {
return m.CompactionRevision
}
return 0
}
func (m *CopyFileRequest) GetStopOffset() uint64 {
if m != nil {
return m.StopOffset
}
return 0
}
type CopyFileResponse struct {
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"`
}
@ -731,6 +747,7 @@ type ReadVolumeFileStatusResponse struct {
DatFileTimestampSeconds uint64 `protobuf:"varint,4,opt,name=dat_file_timestamp_seconds,json=datFileTimestampSeconds" json:"dat_file_timestamp_seconds,omitempty"`
DatFileSize uint64 `protobuf:"varint,5,opt,name=dat_file_size,json=datFileSize" json:"dat_file_size,omitempty"`
FileCount uint64 `protobuf:"varint,6,opt,name=file_count,json=fileCount" json:"file_count,omitempty"`
CompactionRevision uint32 `protobuf:"varint,7,opt,name=compaction_revision,json=compactionRevision" json:"compaction_revision,omitempty"`
}
func (m *ReadVolumeFileStatusResponse) Reset() { *m = ReadVolumeFileStatusResponse{} }
@ -780,6 +797,13 @@ func (m *ReadVolumeFileStatusResponse) GetFileCount() uint64 {
return 0
}
func (m *ReadVolumeFileStatusResponse) GetCompactionRevision() uint32 {
if m != nil {
return m.CompactionRevision
}
return 0
}
type DiskStatus struct {
Dir string `protobuf:"bytes,1,opt,name=dir" json:"dir,omitempty"`
All uint64 `protobuf:"varint,2,opt,name=all" json:"all,omitempty"`
@ -1579,89 +1603,92 @@ var _VolumeServer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("volume_server.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1339 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x58, 0xdd, 0x73, 0x14, 0x45,
0x10, 0xcf, 0x72, 0x97, 0xaf, 0xbe, 0x3b, 0x08, 0x13, 0x20, 0xc7, 0xf2, 0xe1, 0x31, 0x20, 0x1c,
0x1f, 0x06, 0x85, 0x52, 0x51, 0x1f, 0x14, 0x12, 0x2d, 0x53, 0x25, 0x50, 0xb5, 0x01, 0x4a, 0x0b,
0xab, 0xb6, 0x26, 0xbb, 0x93, 0x64, 0x2b, 0x7b, 0xb3, 0xcb, 0xce, 0x6c, 0x24, 0x96, 0xe5, 0x5f,
0xe2, 0x9b, 0xe5, 0x8b, 0x0f, 0xfe, 0x83, 0xbe, 0x58, 0xf3, 0xb1, 0x97, 0xfd, 0xcc, 0x2d, 0xf2,
0x36, 0xdb, 0xd3, 0xdd, 0xbf, 0xee, 0x9e, 0x9e, 0x9e, 0xdf, 0x1d, 0xac, 0x1e, 0x46, 0x61, 0x3a,
0xa1, 0x2e, 0xa7, 0xc9, 0x21, 0x4d, 0xd6, 0xe3, 0x24, 0x12, 0x11, 0x5a, 0x29, 0x08, 0xdd, 0x78,
0x07, 0xdf, 0x07, 0xf4, 0x84, 0x08, 0x6f, 0x7f, 0x93, 0x86, 0x54, 0x50, 0x87, 0xbe, 0x49, 0x29,
0x17, 0xe8, 0x22, 0x2c, 0xed, 0x06, 0x21, 0x75, 0x03, 0x9f, 0x0f, 0xad, 0x51, 0x67, 0xbc, 0xec,
0x2c, 0xca, 0xef, 0x2d, 0x9f, 0xe3, 0xe7, 0xb0, 0x5a, 0x30, 0xe0, 0x71, 0xc4, 0x38, 0x45, 0x8f,
0x60, 0x31, 0xa1, 0x3c, 0x0d, 0x85, 0x36, 0xe8, 0x3d, 0xb8, 0xba, 0x5e, 0xc6, 0x5a, 0x9f, 0x9a,
0xa4, 0xa1, 0x70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, 0x6a, 0x5d, 0x22, 0x82,
0x36, 0x3e, 0x49, 0x25, 0xd7, 0x4d, 0xaf, 0xb3, 0x52, 0x49, 0x96, 0xd4, 0x5c, 0xaa, 0x1c, 0x75,
0x6b, 0x2e, 0x55, 0x9e, 0x68, 0x49, 0xe7, 0x3b, 0x0b, 0xea, 0xef, 0xa1, 0x87, 0xff, 0x05, 0x00,
0x00, 0xff, 0xff, 0xfc, 0x26, 0x3f, 0x74, 0x35, 0x12, 0x00, 0x00,
// 1378 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x58, 0xdb, 0x6e, 0xd4, 0x46,
0x18, 0x8e, 0xd9, 0xcd, 0xe9, 0xdf, 0x5d, 0x08, 0x13, 0x20, 0x8b, 0x39, 0x05, 0x43, 0x61, 0x39,
0x34, 0xb4, 0xa0, 0xb6, 0xb4, 0xbd, 0x68, 0x21, 0x69, 0xd5, 0x48, 0x05, 0x24, 0x07, 0x50, 0x2b,
0x2a, 0x59, 0x13, 0x7b, 0x92, 0x8c, 0xe2, 0xf5, 0x18, 0xcf, 0x98, 0x92, 0xaa, 0xea, 0xcb, 0x54,
0xbd, 0xe9, 0x45, 0x9f, 0xa1, 0x2f, 0xd0, 0x27, 0xea, 0x4d, 0x35, 0x07, 0x7b, 0xd7, 0xa7, 0xac,
0x29, 0x77, 0xe3, 0x6f, 0xfe, 0xf3, 0xfc, 0xf3, 0xcf, 0xb7, 0x0b, 0xab, 0x6f, 0x58, 0x98, 0x8e,
0x89, 0xc7, 0x49, 0xf2, 0x86, 0x24, 0x1b, 0x71, 0xc2, 0x04, 0x43, 0x2b, 0x05, 0xd0, 0x8b, 0x77,
0x9d, 0x7b, 0x80, 0x1e, 0x63, 0xe1, 0x1f, 0x6c, 0x91, 0x90, 0x08, 0xe2, 0x92, 0xd7, 0x29, 0xe1,
0x02, 0x9d, 0x87, 0xa5, 0x3d, 0x1a, 0x12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0x96, 0xbc, 0xeb, 0x53, 0xe4, 0xb0, 0xee, 0xae,
0x57, 0xe9, 0x66, 0xdd, 0x5d, 0xaf, 0x63, 0x98, 0x73, 0x68, 0x17, 0x06, 0x05, 0xba, 0x88, 0x6e,
0x34, 0x69, 0x16, 0x49, 0xa8, 0x7d, 0x73, 0xa6, 0x5c, 0xee, 0xc3, 0xcb, 0xa6, 0x97, 0x19, 0x57,
0x8d, 0xc1, 0x15, 0xe7, 0xd5, 0x8d, 0x59, 0x62, 0xb9, 0x83, 0x1f, 0x01, 0x26, 0xec, 0x0e, 0x5d,
0x6b, 0xd2, 0x9b, 0x3e, 0x8a, 0xeb, 0xc7, 0x0b, 0xe5, 0xa6, 0x7f, 0x86, 0x33, 0x75, 0x2f, 0x39,
0xaa, 0xb9, 0x85, 0xc7, 0xd0, 0x05, 0x7b, 0xa3, 0xad, 0x78, 0xee, 0xf8, 0x05, 0x2c, 0x65, 0x6c,
0x0d, 0x5d, 0xad, 0x6a, 0x97, 0xb8, 0xa8, 0xed, 0x1c, 0x27, 0x32, 0xd5, 0x4d, 0xaf, 0xb2, 0x52,
0x49, 0x5a, 0xd5, 0x5c, 0xaa, 0x29, 0xae, 0xd7, 0x5c, 0xaa, 0x69, 0x66, 0x26, 0x8d, 0xef, 0x2e,
0xa8, 0xbf, 0xa8, 0x1e, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x07, 0x6f, 0xca, 0x8a, 0xb9, 0x12,
0x00, 0x00,
}

31
weed/server/volume_grpc_copy.go

@ -52,9 +52,13 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo
return fmt.Errorf("read volume file status failed, %v", err)
}
// println("source:", volFileInfoResp.String())
copyFileClient, err := client.CopyFile(ctx, &volume_server_pb.CopyFileRequest{
VolumeId: req.VolumeId,
IsIdxFile: true,
CompactionRevision: volFileInfoResp.CompactionRevision,
StopOffset: volFileInfoResp.IdxFileSize,
})
if err != nil {
return fmt.Errorf("failed to start copying volume %d idx file: %v", req.VolumeId, err)
@ -68,6 +72,8 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo
copyFileClient, err = client.CopyFile(ctx, &volume_server_pb.CopyFileRequest{
VolumeId: req.VolumeId,
IsDatFile: true,
CompactionRevision: volFileInfoResp.CompactionRevision,
StopOffset: volFileInfoResp.DatFileSize,
})
if err != nil {
return fmt.Errorf("failed to start copying volume %d dat file: %v", req.VolumeId, err)
@ -161,6 +167,7 @@ func (vs *VolumeServer) ReadVolumeFileStatus(ctx context.Context, req *volume_se
resp.DatFileTimestampSeconds = uint64(modTime.Unix())
resp.IdxFileTimestampSeconds = uint64(modTime.Unix())
resp.FileCount = v.FileCount()
resp.CompactionRevision = uint32(v.CompactionRevision)
return resp, nil
}
@ -171,7 +178,13 @@ func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream v
return fmt.Errorf("not found volume id %d", req.VolumeId)
}
const BufferSize = 1024 * 16
if uint32(v.CompactionRevision) != req.CompactionRevision {
return fmt.Errorf("volume %d is compacted", req.VolumeId)
}
bytesToRead := int64(req.StopOffset)
const BufferSize = 1024 * 1024 * 2
var fileName = v.FileName()
if req.IsDatFile {
fileName += ".dat"
@ -186,19 +199,31 @@ func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream v
buffer := make([]byte, BufferSize)
for {
for bytesToRead > 0 {
bytesread, err := file.Read(buffer)
// println(fileName, "read", bytesread, "bytes, with target", bytesToRead)
if err != nil {
if err != io.EOF {
return err
}
// println(fileName, "read", bytesread, "bytes, with target", bytesToRead, "err", err.Error())
break
}
stream.Send(&volume_server_pb.CopyFileResponse{
if int64(bytesread) > bytesToRead {
bytesread = int(bytesToRead)
}
err = stream.Send(&volume_server_pb.CopyFileResponse{
FileContent: buffer[:bytesread],
})
if err != nil {
// println("sending", bytesread, "bytes err", err.Error())
return err
}
bytesToRead -= int64(bytesread)
}

2
weed/storage/store.go

@ -125,7 +125,7 @@ func (s *Store) Status() []*VolumeInfo {
DeletedByteCount: v.nm.DeletedSize(),
ReadOnly: v.readOnly,
Ttl: v.Ttl,
CompactRevision: uint32(v.CompactRevision),
CompactRevision: uint32(v.CompactionRevision),
}
stats = append(stats, s)
}

2
weed/storage/volume.go

@ -166,6 +166,6 @@ func (v *Volume) ToVolumeInformationMessage() *master_pb.VolumeInformationMessag
ReplicaPlacement: uint32(v.ReplicaPlacement.Byte()),
Version: uint32(v.Version()),
Ttl: v.Ttl.ToUint32(),
CompactRevision: uint32(v.SuperBlock.CompactRevision),
CompactRevision: uint32(v.SuperBlock.CompactionRevision),
}
}

2
weed/storage/volume_backup.go

@ -20,7 +20,7 @@ func (v *Volume) GetVolumeSyncStatus() *volume_server_pb.VolumeSyncStatusRespons
}
syncStatus.Collection = v.Collection
syncStatus.IdxFileSize = v.nm.IndexFileSize()
syncStatus.CompactRevision = uint32(v.SuperBlock.CompactRevision)
syncStatus.CompactRevision = uint32(v.SuperBlock.CompactionRevision)
syncStatus.Ttl = v.SuperBlock.Ttl.String()
syncStatus.Replication = v.SuperBlock.ReplicaPlacement.String()
return syncStatus

6
weed/storage/volume_super_block.go

@ -27,7 +27,7 @@ type SuperBlock struct {
version needle.Version
ReplicaPlacement *ReplicaPlacement
Ttl *needle.TTL
CompactRevision uint16
CompactionRevision uint16
Extra *master_pb.SuperBlockExtra
extraSize uint16
}
@ -48,7 +48,7 @@ func (s *SuperBlock) Bytes() []byte {
header[0] = byte(s.version)
header[1] = s.ReplicaPlacement.Byte()
s.Ttl.ToBytes(header[2:4])
util.Uint16toBytes(header[4:6], s.CompactRevision)
util.Uint16toBytes(header[4:6], s.CompactionRevision)
if s.Extra != nil {
extraData, err := proto.Marshal(s.Extra)
@ -112,7 +112,7 @@ func ReadSuperBlock(dataFile *os.File) (superBlock SuperBlock, err error) {
return
}
superBlock.Ttl = needle.LoadTTLFromBytes(header[2:4])
superBlock.CompactRevision = util.BytesToUint16(header[4:6])
superBlock.CompactionRevision = util.BytesToUint16(header[4:6])
superBlock.extraSize = util.BytesToUint16(header[6:8])
if superBlock.extraSize > 0 {

8
weed/storage/volume_vacuum.go

@ -27,7 +27,7 @@ func (v *Volume) Compact(preallocate int64) error {
filePath := v.FileName()
v.lastCompactIndexOffset = v.nm.IndexFileSize()
v.lastCompactRevision = v.SuperBlock.CompactRevision
v.lastCompactRevision = v.SuperBlock.CompactionRevision
glog.V(3).Infof("creating copies for volume %d ,last offset %d...", v.Id, v.lastCompactIndexOffset)
return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", preallocate)
}
@ -105,7 +105,7 @@ func fetchCompactRevisionFromDatFile(file *os.File) (compactRevision uint16, err
if err != nil {
return 0, err
}
return superBlock.CompactRevision, nil
return superBlock.CompactionRevision, nil
}
func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldIdxFileName string) (err error) {
@ -246,7 +246,7 @@ type VolumeFileScanner4Vacuum struct {
func (scanner *VolumeFileScanner4Vacuum) VisitSuperBlock(superBlock SuperBlock) error {
scanner.version = superBlock.Version()
superBlock.CompactRevision++
superBlock.CompactionRevision++
_, err := scanner.dst.Write(superBlock.Bytes())
scanner.newOffset = int64(superBlock.BlockSize())
return err
@ -321,7 +321,7 @@ func (v *Volume) copyDataBasedOnIndexFile(dstName, idxName string) (err error) {
nm := NewBtreeNeedleMap(idx)
now := uint64(time.Now().Unix())
v.SuperBlock.CompactRevision++
v.SuperBlock.CompactionRevision++
dst.Write(v.SuperBlock.Bytes())
newOffset := int64(v.SuperBlock.BlockSize())

Loading…
Cancel
Save