internal/unionstore: avoid panic and add log for tidb issue/34307 (#482)

Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>
This commit is contained in:
tiancaiamao 2022-04-28 14:21:51 +08:00 committed by GitHub
parent b3d61828e5
commit 577843f1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -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.