From cc70cd2329ce6508ad6c1b95e7e51c12b07955de Mon Sep 17 00:00:00 2001 From: Natalie Villasana Date: Tue, 17 Sep 2019 15:18:48 -0400 Subject: [PATCH] satellite/repair: add metric trackers for segment age before repair (#3056) --- pkg/pb/pointerdb.pb.go | 111 +++++++++++++++----------- pkg/pb/pointerdb.proto | 3 + proto.lock | 20 +++++ satellite/metainfo/service.go | 3 + satellite/repair/checker/checker.go | 11 +++ satellite/repair/repairer/segments.go | 19 ++++- 6 files changed, 120 insertions(+), 47 deletions(-) diff --git a/pkg/pb/pointerdb.pb.go b/pkg/pb/pointerdb.pb.go index 5f1330a23..de1350069 100644 --- a/pkg/pb/pointerdb.pb.go +++ b/pkg/pb/pointerdb.pb.go @@ -263,6 +263,8 @@ type Pointer struct { CreationDate time.Time `protobuf:"bytes,6,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"` ExpirationDate time.Time `protobuf:"bytes,7,opt,name=expiration_date,json=expirationDate,proto3,stdtime" json:"expiration_date"` Metadata []byte `protobuf:"bytes,8,opt,name=metadata,proto3" json:"metadata,omitempty"` + LastRepaired time.Time `protobuf:"bytes,9,opt,name=last_repaired,json=lastRepaired,proto3,stdtime" json:"last_repaired"` + RepairCount int32 `protobuf:"varint,10,opt,name=repair_count,json=repairCount,proto3" json:"repair_count,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -341,6 +343,20 @@ func (m *Pointer) GetMetadata() []byte { return nil } +func (m *Pointer) GetLastRepaired() time.Time { + if m != nil { + return m.LastRepaired + } + return time.Time{} +} + +func (m *Pointer) GetRepairCount() int32 { + if m != nil { + return m.RepairCount + } + return 0 +} + // ListResponse is a response message for the List rpc call type ListResponse struct { Items []*ListResponse_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` @@ -456,51 +472,54 @@ func init() { func init() { proto.RegisterFile("pointerdb.proto", fileDescriptor_75fef806d28fc810) } var fileDescriptor_75fef806d28fc810 = []byte{ - // 735 bytes of a gzipped FileDescriptorProto + // 770 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x36, 0x2d, 0x89, 0xa2, 0x87, 0x94, 0xad, 0x2c, 0x8a, 0x96, 0x50, 0x0a, 0xc8, 0x21, 0x90, - 0xd6, 0x45, 0x03, 0xba, 0x60, 0x6e, 0xcd, 0xa9, 0x86, 0x0c, 0x94, 0x80, 0xa3, 0x1a, 0x2b, 0xa1, - 0x87, 0x5e, 0x88, 0x95, 0x38, 0x11, 0x17, 0x15, 0xb9, 0xcc, 0xee, 0x0a, 0x88, 0xfd, 0x14, 0x79, - 0x8a, 0xbe, 0x45, 0xef, 0x7d, 0x86, 0x1e, 0x92, 0x57, 0x29, 0xb8, 0x4b, 0x4a, 0x4a, 0x03, 0x14, - 0xe8, 0x85, 0x9c, 0x9f, 0x6f, 0x7e, 0xf6, 0x9b, 0x19, 0xb8, 0xa8, 0x05, 0xaf, 0x34, 0xca, 0x7c, - 0x15, 0xd7, 0x52, 0x68, 0x41, 0xce, 0xf6, 0x86, 0xc9, 0x74, 0x23, 0xc4, 0x66, 0x8b, 0xd7, 0xc6, - 0xb1, 0xda, 0xbd, 0xb9, 0xd6, 0xbc, 0x44, 0xa5, 0x59, 0x59, 0x5b, 0xec, 0x04, 0x36, 0x62, 0x23, - 0x3a, 0xb9, 0x12, 0x39, 0xb6, 0x72, 0x20, 0x64, 0x8e, 0x52, 0x59, 0x2d, 0xfa, 0xe3, 0x14, 0xc6, - 0x14, 0xf3, 0x5d, 0x95, 0xb3, 0x6a, 0xfd, 0xb0, 0x58, 0x17, 0x58, 0x22, 0xf9, 0x11, 0xfa, 0xfa, - 0xa1, 0xc6, 0xd0, 0xb9, 0x74, 0xae, 0xce, 0x93, 0x6f, 0xe2, 0x43, 0x1b, 0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, 0x5c, 0xc3, 0xd9, - 0xcb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x73, 0x81, 0x70, 0xa2, 0x4b, 0x05, 0x00, 0x00, + 0x10, 0x36, 0xad, 0x5f, 0x0f, 0x29, 0x5b, 0x59, 0x14, 0x2d, 0xa1, 0x14, 0x90, 0x43, 0x20, 0xad, + 0x8b, 0x06, 0x74, 0xc1, 0xdc, 0x9a, 0x53, 0x5d, 0x19, 0x28, 0x01, 0x47, 0x35, 0x56, 0x46, 0x0f, + 0xbd, 0x10, 0x2b, 0x71, 0x22, 0x2e, 0x2a, 0x72, 0x99, 0xdd, 0x15, 0x10, 0xfb, 0x29, 0xfa, 0x14, + 0x7d, 0x8b, 0xde, 0xfb, 0x0c, 0x3d, 0x24, 0x6f, 0x52, 0x14, 0xbb, 0x4b, 0x4a, 0x4a, 0x03, 0x14, + 0xf0, 0x45, 0xda, 0x99, 0xf9, 0xe6, 0x87, 0xdf, 0x7c, 0x03, 0x67, 0xb5, 0xe0, 0x95, 0x46, 0x99, + 0x2f, 0xe3, 0x5a, 0x0a, 0x2d, 0xc8, 0xc9, 0xce, 0x31, 0x99, 0xae, 0x85, 0x58, 0x6f, 0xf0, 0xd2, + 0x06, 0x96, 0xdb, 0x37, 0x97, 0x9a, 0x97, 0xa8, 0x34, 0x2b, 0x6b, 0x87, 0x9d, 0xc0, 0x5a, 0xac, + 0x45, 0xfb, 0xae, 0x44, 0x8e, 0xcd, 0x3b, 0x10, 0x32, 0x47, 0xa9, 0x9c, 0x15, 0xfd, 0x71, 0x0c, + 0x63, 0x8a, 0xf9, 0xb6, 0xca, 0x59, 0xb5, 0xba, 0x5f, 0xac, 0x0a, 0x2c, 0x91, 0x7c, 0x0f, 0x5d, + 0x7d, 0x5f, 0x63, 0xe8, 0x9d, 0x7b, 0x17, 0xa7, 0xc9, 0x57, 0xf1, 0x7e, 0x8c, 0xff, 0x42, 0x63, + 0xf7, 0x77, 0x77, 0x5f, 0x23, 0xb5,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a9, 0xd8, 0x68, 0x0b, 0x31, 0x27, 0xcf, 0x55, 0x56, 0x4b, 0x7c, 0xc3, + 0xdf, 0x59, 0x85, 0x0d, 0xe9, 0x90, 0xab, 0x5b, 0x6b, 0x5f, 0x75, 0x7f, 0x3d, 0xae, 0x97, 0xcb, + 0xbe, 0x25, 0xee, 0xe5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x81, 0x7b, 0x5c, 0x68, 0xb9, 0x05, + 0x00, 0x00, } diff --git a/pkg/pb/pointerdb.proto b/pkg/pb/pointerdb.proto index efa581edc..ee773ee31 100644 --- a/pkg/pb/pointerdb.proto +++ b/pkg/pb/pointerdb.proto @@ -56,6 +56,9 @@ message Pointer { google.protobuf.Timestamp expiration_date = 7 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; bytes metadata = 8; + + google.protobuf.Timestamp last_repaired = 9 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + int32 repair_count = 10; } // ListResponse is a response message for the List rpc call diff --git a/proto.lock b/proto.lock index 2756e4da7..4c8bcce78 100644 --- a/proto.lock +++ b/proto.lock @@ -5530,6 +5530,26 @@ "id": 8, "name": "metadata", "type": "bytes" + }, + { + "id": 9, + "name": "last_repaired", + "type": "google.protobuf.Timestamp", + "options": [ + { + "name": "(gogoproto.stdtime)", + "value": "true" + }, + { + "name": "(gogoproto.nullable)", + "value": "false" + } + ] + }, + { + "id": 10, + "name": "repair_count", + "type": "int32" } ] }, diff --git a/satellite/metainfo/service.go b/satellite/metainfo/service.go index c06b4cf5a..b8e282501 100644 --- a/satellite/metainfo/service.go +++ b/satellite/metainfo/service.go @@ -118,6 +118,9 @@ func (s *Service) UpdatePieces(ctx context.Context, path string, ref *pb.Pointer } pointer.GetRemote().RemotePieces = pieces + pointer.LastRepaired = ref.LastRepaired + pointer.RepairCount = ref.RepairCount + // marshal the pointer newPointerBytes, err := proto.Marshal(pointer) if err != nil { diff --git a/satellite/repair/checker/checker.go b/satellite/repair/checker/checker.go index f7fe82c50..5ef1a2c83 100644 --- a/satellite/repair/checker/checker.go +++ b/satellite/repair/checker/checker.go @@ -244,6 +244,9 @@ func (obs *checkerObserver) RemoteSegment(ctx context.Context, path metainfo.Sco mon.IntVal("checker_segment_total_count").Observe(int64(len(pieces))) mon.IntVal("checker_segment_healthy_count").Observe(int64(numHealthy)) + segmentAge := time.Since(pointer.CreationDate) + mon.IntVal("checker_segment_age").Observe(int64(segmentAge.Seconds())) + redundancy := pointer.Remote.Redundancy // we repair when the number of healthy pieces is less than or equal to the repair threshold and is greater or equal to @@ -293,6 +296,14 @@ func (obs *checkerObserver) RemoteSegment(ctx context.Context, path metainfo.Sco } } + var segmentAge time.Duration + if pointer.CreationDate.Before(pointer.LastRepaired) { + segmentAge = time.Since(pointer.LastRepaired) + } else { + segmentAge = time.Since(pointer.CreationDate) + } + mon.IntVal("checker_segment_time_until_irreparable").Observe(int64(segmentAge.Seconds())) + obs.monStats.remoteSegmentsLost++ // make an entry into the irreparable table segmentInfo := &pb.IrreparableSegment{ diff --git a/satellite/repair/repairer/segments.go b/satellite/repair/repairer/segments.go index c8668f89e..39fde2264 100644 --- a/satellite/repair/repairer/segments.go +++ b/satellite/repair/repairer/segments.go @@ -248,9 +248,26 @@ func (repairer *SegmentRepairer) Repair(ctx context.Context, path storj.Path) (s // add pieces that failed piece hashes verification to the removal list toRemove = append(toRemove, failedPieces...) + pointer.LastRepaired = time.Now().UTC() + pointer.RepairCount++ + // Update the segment pointer in the metainfo _, err = repairer.metainfo.UpdatePieces(ctx, path, pointer, repairedPieces, toRemove) - return err == nil, err + if err != nil { + return false, err + } + + var segmentAge time.Duration + if pointer.CreationDate.Before(pointer.LastRepaired) { + segmentAge = time.Since(pointer.LastRepaired) + } else { + segmentAge = time.Since(pointer.CreationDate) + } + + mon.IntVal("segment_time_until_repair").Observe(int64(segmentAge.Seconds())) + mon.IntVal("segment_repair_count").Observe(int64(pointer.RepairCount)) + + return true, nil } func (repairer *SegmentRepairer) updateAuditFailStatus(ctx context.Context, failedAuditNodeIDs storj.NodeIDList) (failedNum int, err error) {