diff options
| author | chrislu <chris.lu@gmail.com> | 2022-10-28 12:53:23 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-10-28 12:53:23 -0700 |
| commit | 0d9f2f9e7a3a4cda273ef1d057c7f2b052b985d9 (patch) | |
| tree | 3020c8bd10e1a675c260f5c9a8c404bc5bdf8984 /weed/shell/command_volume_check_disk.go | |
| parent | ea2637734a13a08d11d4f26e80c1324664bf7ffc (diff) | |
| parent | 764d9cb1059e5210927c7faca79012578fe69119 (diff) | |
| download | seaweedfs-0d9f2f9e7a3a4cda273ef1d057c7f2b052b985d9.tar.xz seaweedfs-0d9f2f9e7a3a4cda273ef1d057c7f2b052b985d9.zip | |
Merge branch 'master' of https://github.com/seaweedfs/seaweedfs
Diffstat (limited to 'weed/shell/command_volume_check_disk.go')
| -rw-r--r-- | weed/shell/command_volume_check_disk.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/weed/shell/command_volume_check_disk.go b/weed/shell/command_volume_check_disk.go index 7195318fb..41c28b810 100644 --- a/weed/shell/command_volume_check_disk.go +++ b/weed/shell/command_volume_check_disk.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc" "io" "math" + "time" ) func init() { @@ -121,6 +122,7 @@ func (c *commandVolumeCheckDisk) checkBoth(a *VolumeReplica, b *VolumeReplica, a }() // read index db + readIndexDbCutoffFrom := uint64(time.Now().UnixNano()) if err = c.readIndexDatabase(aDB, a.info.Collection, a.info.Id, pb.NewServerAddressFromDataNode(a.location.dataNode), verbose, writer); err != nil { return true, true, fmt.Errorf("readIndexDatabase %s volume %d: %v", a.location.dataNode, a.info.Id, err) } @@ -129,25 +131,37 @@ func (c *commandVolumeCheckDisk) checkBoth(a *VolumeReplica, b *VolumeReplica, a } // find and make up the differences - if aHasChanges, err = c.doVolumeCheckDisk(bDB, aDB, b, a, verbose, writer, applyChanges, nonRepairThreshold); err != nil { + if aHasChanges, err = c.doVolumeCheckDisk(bDB, aDB, b, a, verbose, writer, applyChanges, nonRepairThreshold, readIndexDbCutoffFrom); err != nil { return true, true, fmt.Errorf("doVolumeCheckDisk source:%s target:%s volume %d: %v", b.location.dataNode.Id, a.location.dataNode.Id, b.info.Id, err) } - if bHasChanges, err = c.doVolumeCheckDisk(aDB, bDB, a, b, verbose, writer, applyChanges, nonRepairThreshold); err != nil { + if bHasChanges, err = c.doVolumeCheckDisk(aDB, bDB, a, b, verbose, writer, applyChanges, nonRepairThreshold, readIndexDbCutoffFrom); err != nil { return true, true, fmt.Errorf("doVolumeCheckDisk source:%s target:%s volume %d: %v", a.location.dataNode.Id, b.location.dataNode.Id, a.info.Id, err) } return } -func (c *commandVolumeCheckDisk) doVolumeCheckDisk(minuend, subtrahend *needle_map.MemDb, source, target *VolumeReplica, verbose bool, writer io.Writer, applyChanges bool, nonRepairThreshold float64) (hasChanges bool, err error) { +func (c *commandVolumeCheckDisk) doVolumeCheckDisk(minuend, subtrahend *needle_map.MemDb, source, target *VolumeReplica, verbose bool, writer io.Writer, applyChanges bool, nonRepairThreshold float64, cutoffFromAtNs uint64) (hasChanges bool, err error) { // find missing keys // hash join, can be more efficient var missingNeedles []needle_map.NeedleValue var counter int - minuend.AscendingVisit(func(value needle_map.NeedleValue) error { + doCutoffOfLastNeedle := true + minuend.DescendingVisit(func(value needle_map.NeedleValue) error { counter++ - if _, found := subtrahend.Get(value.Key); !found && value.Size.IsValid() { + if _, found := subtrahend.Get(value.Key); !found { + if doCutoffOfLastNeedle { + if needleMeta, err := readNeedleMeta(c.env.option.GrpcDialOption, pb.NewServerAddressFromDataNode(source.location.dataNode), source.info.Id, value); err == nil { + // needles older than the cutoff time are not missing yet + if needleMeta.AppendAtNs > cutoffFromAtNs { + return nil + } + doCutoffOfLastNeedle = false + } + } missingNeedles = append(missingNeedles, value) + } else if doCutoffOfLastNeedle { + doCutoffOfLastNeedle = false } return nil }) @@ -166,7 +180,6 @@ func (c *commandVolumeCheckDisk) doVolumeCheckDisk(minuend, subtrahend *needle_m } for _, needleValue := range missingNeedles { - needleBlob, err := readSourceNeedleBlob(c.env.option.GrpcDialOption, pb.NewServerAddressFromDataNode(source.location.dataNode), source.info.Id, needleValue) if err != nil { return hasChanges, err |
