fix(datanode): The contents on which the CRC check depends are inconsistent with each other

Update the crc check output from error to warn, the inconsistent may be false report and require
more output and make a jugement.

The applyId and crc cann't be atomic under the architecture and are not necessary for performance.

Signed-off-by: leonrayang <chl696@sina.com>
This commit is contained in:
leonrayang 2024-06-12 19:51:23 +08:00 committed by longerfly
parent c9611557a2
commit 5c82a084f1
3 changed files with 10 additions and 15 deletions

View File

@ -205,4 +205,5 @@ func (dp *DataPartition) Del(key interface{}) (interface{}, error) {
func (dp *DataPartition) uploadApplyID(applyID uint64) {
log.LogDebugf("[uploadApplyID] dp(%v) upload apply id(%v)", dp.partitionID, applyID)
atomic.StoreUint64(&dp.appliedID, applyID)
atomic.StoreUint64(&dp.extentStore.ApplyId, applyID)
}

View File

@ -72,6 +72,7 @@ type ExtentInfo struct {
SnapshotDataOff uint64 `json:"snapSize"`
SnapPreAllocDataOff uint64 `json:"snapPreAllocSize"`
ApplyID uint64 `json:"applyID"`
ApplySize int64 `json:"ApplySize"`
}
func (ei *ExtentInfo) TotalSize() uint64 {
@ -577,12 +578,8 @@ func (e *Extent) GetCrc(blockNo int64) uint32 {
return binary.BigEndian.Uint32(e.header[blockNo*util.PerBlockCrcSize : (blockNo+1)*util.PerBlockCrcSize])
}
func (e *Extent) autoComputeExtentCrc(crcFunc UpdateCrcFunc) (crc uint32, err error) {
func (e *Extent) autoComputeExtentCrc(extSize int64, crcFunc UpdateCrcFunc) (crc uint32, err error) {
var blockCnt int
extSize := e.Size()
if e.snapshotDataOff > util.ExtentSize {
extSize = int64(e.snapshotDataOff)
}
blockCnt = int(extSize / util.BlockSize)
if extSize%util.BlockSize != 0 {
blockCnt += 1

View File

@ -149,7 +149,6 @@ type ExtentStore struct {
extentLock bool
stopMutex sync.RWMutex
stopC chan interface{}
ApplyIdMutex sync.RWMutex
ApplyId uint64
}
@ -1541,9 +1540,7 @@ func (s *ExtentStore) autoComputeExtentCrc() {
sort.Sort(ExtentInfoArr(extentInfos))
for _, ei := range extentInfos {
s.ApplyIdMutex.RLock()
if ei == nil {
s.ApplyIdMutex.RUnlock()
continue
}
@ -1553,22 +1550,22 @@ func (s *ExtentStore) autoComputeExtentCrc() {
e, err := s.extentWithHeader(ei)
if err != nil {
log.LogWarnf("[autoComputeExtentCrc] get extent error:%+v", err)
s.ApplyIdMutex.RUnlock()
continue
}
extentCrc, err := e.autoComputeExtentCrc(s.PersistenceBlockCrc)
extSize := e.Size()
if e.snapshotDataOff > util.ExtentSize {
extSize = int64(e.snapshotDataOff)
}
extentCrc, err := e.autoComputeExtentCrc(extSize, s.PersistenceBlockCrc)
if err != nil {
log.LogError("[autoComputeExtentCrc] compute crc fail", err)
s.ApplyIdMutex.RUnlock()
continue
}
ei.ApplySize = extSize
ei.UpdateExtentInfo(e, extentCrc)
ei.ApplyID = s.ApplyId
atomic.StoreUint64(&ei.ApplyID, s.ApplyId)
time.Sleep(time.Millisecond * 100)
}
s.ApplyIdMutex.RUnlock()
}
time.Sleep(time.Second)