From 02e93f8aac4db025431a66c164b725c648d2f9a3 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 8 Dec 2021 10:00:37 +0800 Subject: [PATCH] mockstore: improve log to avoid nil pointer Signed-off-by: Weizhen Wang --- store/mockstore/unistore/tikv/region.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/store/mockstore/unistore/tikv/region.go b/store/mockstore/unistore/tikv/region.go index 932841c968927..d854c910047a9 100644 --- a/store/mockstore/unistore/tikv/region.go +++ b/store/mockstore/unistore/tikv/region.go @@ -248,7 +248,13 @@ func (ri *regionCtx) AcquireLatches(hashVals []uint64) { dur := time.Since(start) metrics.LatchWait.Observe(dur.Seconds()) if dur > time.Millisecond*50 { - log.S().Warnf("region %d acquire %d locks takes %v, waitCnt %d", ri.meta.Id, len(hashVals), dur, waitCnt) + var id string + if ri.meta == nil { + id = "unknown" + } else { + id = strconv.FormatUint(ri.meta.Id, 10) + } + log.S().Warnf("region %s acquire %d locks takes %v, waitCnt %d", id, len(hashVals), dur, waitCnt) } }