diff --git a/internal/unionstore/memdb_arena.go b/internal/unionstore/memdb_arena.go index 5addc883..db83e465 100644 --- a/internal/unionstore/memdb_arena.go +++ b/internal/unionstore/memdb_arena.go @@ -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.