|
@ -14,7 +14,7 @@ import ( |
|
|
"github.com/seaweedfs/seaweedfs/weed/util" |
|
|
"github.com/seaweedfs/seaweedfs/weed/util" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uint64, err error) { |
|
|
|
|
|
|
|
|
func CheckVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uint64, err error) { |
|
|
var indexSize int64 |
|
|
var indexSize int64 |
|
|
if indexSize, err = verifyIndexFileIntegrity(indexFile); err != nil { |
|
|
if indexSize, err = verifyIndexFileIntegrity(indexFile); err != nil { |
|
|
return 0, fmt.Errorf("verifyIndexFileIntegrity %s failed: %v", indexFile.Name(), err) |
|
|
return 0, fmt.Errorf("verifyIndexFileIntegrity %s failed: %v", indexFile.Name(), err) |
|
@ -35,11 +35,7 @@ func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAt |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if healthyIndexSize < indexSize { |
|
|
if healthyIndexSize < indexSize { |
|
|
glog.Warningf("CheckAndFixVolumeDataIntegrity truncate idx file %s from %d to %d", indexFile.Name(), indexSize, healthyIndexSize) |
|
|
|
|
|
err = indexFile.Truncate(healthyIndexSize) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
glog.Warningf("CheckAndFixVolumeDataIntegrity truncate idx file %s from %d to %d: %v", indexFile.Name(), indexSize, healthyIndexSize, err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return 0, fmt.Errorf("CheckVolumeDataIntegrity %s failed: index size %d differs from healthy size %d", indexFile.Name(), indexSize, healthyIndexSize) |
|
|
} |
|
|
} |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|