tidb-server重启后stats一直没有加载成功,期间有一个panic报错。最终导致的结果是:重启后的tidb-server上的SQL都走了pseudo逻辑,很多正常的查询都走错索引了,所有TiKV节点负载都很高
报错内容为:
[ERROR] [misc.go:116] ["panic in the recoverable goroutine"] [label=domain] [funcInfo=loadStatsWorker] [r="invalid memory address or nil pointer dereference"] [stack=github.com/pingcap/tidb/util.Recover
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/misc.go:120
runtime.gopanic
/usr/local/go/src/runtime/panic.go:884
github.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:440
runtime.gopanic
/usr/local/go/src/runtime/panic.go:884
runtime.panicmem
/usr/local/go/src/runtime/panic.go:260
runtime.sigpanic
/usr/local/go/src/runtime/signal_unix.go:835
github.com/pingcap/tidb/session.(*LazyTxn).SetOption
<autogenerated>:1
github.com/pingcap/tidb/sessiontxn/isolation.(*PessimisticRCTxnContextProvider).getStmtTS
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/sessiontxn/isolation/readcommitted.go:193
github.com/pingcap/tidb/sessiontxn/isolation.(*baseTxnContextProvider).GetStmtReadTS
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/sessiontxn/isolation/base.go:189
github.com/pingcap/tidb/session.(*txnManager).GetStmtReadTS
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/txnmanager.go:84
github.com/pingcap/tidb/executor.(*executorBuilder).getSnapshotTS
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:1736
github.com/pingcap/tidb/executor.buildNoRangeIndexLookUpReader
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:3780
github.com/pingcap/tidb/executor.(*executorBuilder).buildIndexLookUpReader
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:3851
github.com/pingcap/tidb/executor.(*executorBuilder).build
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:287
github.com/pingcap/tidb/executor.(*executorBuilder).buildProjection
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:1685
github.com/pingcap/tidb/executor.(*executorBuilder).build
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:269
github.com/pingcap/tidb/executor.(*executorBuilder).buildStreamAgg
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:1641
github.com/pingcap/tidb/executor.(*executorBuilder).build
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:267
github.com/pingcap/tidb/executor.(*ExecStmt).buildExecutor
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:1098
github.com/pingcap/tidb/executor.(*ExecStmt).Exec
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:500
github.com/pingcap/tidb/session.runStmt
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2351
github.com/pingcap/tidb/session.(*session).ExecuteStmt
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2215
github.com/pingcap/tidb/session.(*session).ExecuteInternal
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1676
github.com/pingcap/tidb/statistics/handle.(*Handle).initTopNCountSum
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/bootstrap.go:338
github.com/pingcap/tidb/statistics/handle.(*Handle).initStatsHistograms4Chunk
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/bootstrap.go:144
github.com/pingcap/tidb/statistics/handle.(*Handle).initStatsHistograms
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/bootstrap.go:185
github.com/pingcap/tidb/statistics/handle.(*Handle).InitStats
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/bootstrap.go:415
github.com/pingcap/tidb/domain.(*Domain).loadStatsWorker
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/domain/domain.go:1882
github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1
/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/wait_group_wrapper.go:33