mirror of https://github.com/tikv/client-go.git
internal/unionstore: avoid panic and add log for tidb issue/34307 (#482)
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>
This commit is contained in:
parent
b3d61828e5
commit
577843f1b9
|
|
@ -39,7 +39,9 @@ import (
|
|||
"math"
|
||||
"unsafe"
|
||||
|
||||
"github.com/tikv/client-go/v2/internal/logutil"
|
||||
"github.com/tikv/client-go/v2/kv"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -61,7 +63,17 @@ type memdbArenaAddr struct {
|
|||
}
|
||||
|
||||
func (addr memdbArenaAddr) isNull() bool {
|
||||
return addr == nullAddr
|
||||
if addr == nullAddr {
|
||||
return true
|
||||
}
|
||||
if addr.idx == math.MaxUint32 || addr.off == math.MaxUint32 {
|
||||
// defensive programming, the code should never run to here.
|
||||
// it always means something wrong... (maybe caused by data race?)
|
||||
// because we never set part of idx/off to math.MaxUint64
|
||||
logutil.BgLogger().Warn("Invalid memdbArenaAddr", zap.Uint32("idx", addr.idx), zap.Uint32("off", addr.off))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// store and load is used by vlog, due to pointer in vlog is not aligned.
|
||||
|
|
|
|||
Loading…
Reference in New Issue