tidb-server重启后stats一直没有加载成功

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

loadStatsWorker panic when init stats · Issue #41938 · pingcap/tidb (github.com)
应该是现有的bug,可以看看这个,
The updateStatsWorker goroutine panic with invalid memory addr or nil pointer ref · Issue #35421 · pingcap/tidb (github.com)

[funcInfo=loadStatsWorker] [r=“"time: missing Location in call to Date"”]

issue里的报错是这个,是时区问题导致的。和我的问题应该还不一样

已经在6.5.3缓解了统计信息加载慢的问题,到7.1才真正解决,如果也遇到这个问题,少年,你该升级版本了 :grinning:

升级版本,可以升级到6.5最新版本

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。