invalid memory address or nil pointer dereference

执行 SELECT * FROM information_schema.key_column_usage 报错:

[Code: 1105, SQL State: HY000] runtime error: invalid memory address or nil pointer dereference

1 个赞

看下 tidb-server 是不是重启了、、
执行下 select tidb_version();

select tidb_version()

Release Version: v4.0.2
Edition: Community
Git Commit Hash: 328b6d0a955c4668cf3188d02a6df42e16eaab4e
Git Branch: heads/refs/tags/v4.0.2
UTC Build Time: 2020-07-01 08:19:48
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

select * from information_schema.cluster_info;

在 tidb log 中看下执行 sql 时间点附近的日志,上传下这边看下。

[2020/07/24 16:53:51.073 +08:00] [INFO] [set.go:207] [“set session var”] [conn=50133] [name=sql_select_limit] [val=18446744073709551615]
[2020/07/24 16:53:51.101 +08:00] [INFO] [set.go:207] [“set session var”] [conn=50133] [name=sql_select_limit] [val=1000]
[2020/07/24 16:53:51.133 +08:00] [ERROR] [adapter.go:123] [“execute sql panic”] [conn=50133] [sql=“SELECT * FROM information_schema.key_column_usage”] [stack=“github.com/pingcap/tidb/executor.(*recordSet).Next.func1\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/adapter.go:123\ runtime.gopanic\ \t/usr/local/go/src/runtime/panic.go:679\ runtime.panicmem\ \t/usr/local/go/src/runtime/panic.go:199\ runtime.sigpanic\ \t/usr/local/go/src/runtime/signal_unix.go:394\ngithub.com/pingcap/tidb/executor.keyColumnUsageInTable\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:1144\ github.com/pingcap/tidb/executor.(*memtableRetriever).setDataFromKeyColumnUsage\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:999\ngithub.com/pingcap/tidb/executor.(*memtableRetriever).retrieve\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:99\ngithub.com/pingcap/tidb/executor.(*MemTableReaderExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/memtable_reader.go:108\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:248\ github.com/pingcap/tidb/executor.(*LimitExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:982\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:248\ github.com/pingcap/tidb/executor.(*recordSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/adapter.go:126\ngithub.com/pingcap/tidb/server.(*tidbResultSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/driver_tidb.go:386\ngithub.com/pingcap/tidb/server.(*clientConn).writeChunksWithFetchSize\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:1452\ngithub.com/pingcap/tidb/server.(*clientConn).writeResultset\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:1369\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmtFetch\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn_stmt.go:243\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:914\ngithub.com/pingcap/tidb/server.(*clientConn).Run\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:713\ngithub.com/pingcap/tidb/server.(*Server).onConn\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/server.go:415”]
[2020/07/24 16:53:51.134 +08:00] [ERROR] [conn.go:728] [“command dispatched failed”] [conn=50133] [connInfo=“id:50133, addr:10.10.5.28:54962 status:10, collation:utf8_general_ci, user:health_dev”] [command=Fetch] [status=“inTxn:0, autocommit:1”] [sql=“SELECT * FROM information_schema.key_column_usage”] [txn_mode=OPTIMISTIC] [err=“runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/tidb/executor.(*recordSet).Next.func1\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/adapter.go:122\ runtime.gopanic\ \t/usr/local/go/src/runtime/panic.go:679\ runtime.panicmem\ \t/usr/local/go/src/runtime/panic.go:199\ runtime.sigpanic\ \t/usr/local/go/src/runtime/signal_unix.go:394\ngithub.com/pingcap/tidb/executor.keyColumnUsageInTable\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:1144\ github.com/pingcap/tidb/executor.(*memtableRetriever).setDataFromKeyColumnUsage\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:999\ngithub.com/pingcap/tidb/executor.(*memtableRetriever).retrieve\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:99\ngithub.com/pingcap/tidb/executor.(*MemTableReaderExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/memtable_reader.go:108\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:248\ github.com/pingcap/tidb/executor.(*LimitExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:982\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/executor.go:248\ github.com/pingcap/tidb/executor.(*recordSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/executor/adapter.go:126\ngithub.com/pingcap/tidb/server.(*tidbResultSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/driver_tidb.go:386\ngithub.com/pingcap/tidb/server.(*clientConn).writeChunksWithFetchSize\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:1452\ngithub.com/pingcap/tidb/server.(*clientConn).writeResultset\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:1369\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmtFetch\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn_stmt.go:243\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:914\ngithub.com/pingcap/tidb/server.(*clientConn).Run\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/conn.go:713\ngithub.com/pingcap/tidb/server.(*Server).onConn\ \t/home/jenkins/agent/workspace/tidb_v4.0.2/go/src/github.com/pingcap/tidb/server/server.go:415\ runtime.goexit\ \t/usr/local/go/src/runtime/asm_amd64.s:1357\ SELECT * FROM information_schema.key_column_usage”]

本地测试没有复现,问题我们再跟进下,有消息会及时同步。

刚升级到了 4.0.3 还是有这个错误,日志如下:

[2020/07/26 21:54:57.064 +08:00] [INFO] [set.go:207] [“set session var”] [conn=42] [name=sql_select_limit] [val=18446744073709551615]
[2020/07/26 21:54:57.197 +08:00] [INFO] [set.go:207] [“set session var”] [conn=42] [name=sql_select_limit] [val=1000]
[2020/07/26 21:54:57.290 +08:00] [ERROR] [adapter.go:123] [“execute sql panic”] [conn=42] [sql=“SELECT * FROM information_schema.key_column_usage”] [stack=“github.com/pingcap/tidb/executor.(*recordSet).Next.func1\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/adapter.go:123\ runtime.gopanic\ \t/usr/local/go/src/runtime/panic.go:679\ runtime.panicmem\ \t/usr/local/go/src/runtime/panic.go:199\ runtime.sigpanic\ \t/usr/local/go/src/runtime/signal_unix.go:394\ngithub.com/pingcap/tidb/executor.keyColumnUsageInTable\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:1143\ github.com/pingcap/tidb/executor.(*memtableRetriever).setDataFromKeyColumnUsage\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:998\ngithub.com/pingcap/tidb/executor.(*memtableRetriever).retrieve\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:104\ngithub.com/pingcap/tidb/executor.(*MemTableReaderExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/memtable_reader.go:108\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:249\ github.com/pingcap/tidb/executor.(*LimitExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:1012\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:249\ github.com/pingcap/tidb/executor.(*recordSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/adapter.go:126\ngithub.com/pingcap/tidb/server.(*tidbResultSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/driver_tidb.go:386\ngithub.com/pingcap/tidb/server.(*clientConn).writeChunksWithFetchSize\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:1459\ngithub.com/pingcap/tidb/server.(*clientConn).writeResultset\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:1376\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmtFetch\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn_stmt.go:243\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:921\ngithub.com/pingcap/tidb/server.(*clientConn).Run\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:715\ngithub.com/pingcap/tidb/server.(*Server).onConn\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/server.go:415”]
[2020/07/26 21:54:57.290 +08:00] [ERROR] [conn.go:730] [“command dispatched failed”] [conn=42] [connInfo=“id:42, addr:10.10.5.28:47246 status:10, collation:utf8_general_ci, user:health_dev”] [command=Fetch] [status=“inTxn:0, autocommit:1”] [sql=“SELECT * FROM information_schema.key_column_usage”] [txn_mode=OPTIMISTIC] [err=“runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/tidb/executor.(*recordSet).Next.func1\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/adapter.go:122\ runtime.gopanic\ \t/usr/local/go/src/runtime/panic.go:679\ runtime.panicmem\ \t/usr/local/go/src/runtime/panic.go:199\ runtime.sigpanic\ \t/usr/local/go/src/runtime/signal_unix.go:394\ngithub.com/pingcap/tidb/executor.keyColumnUsageInTable\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:1143\ github.com/pingcap/tidb/executor.(*memtableRetriever).setDataFromKeyColumnUsage\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:998\ngithub.com/pingcap/tidb/executor.(*memtableRetriever).retrieve\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/infoschema_reader.go:104\ngithub.com/pingcap/tidb/executor.(*MemTableReaderExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/memtable_reader.go:108\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:249\ github.com/pingcap/tidb/executor.(*LimitExec).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:1012\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/executor.go:249\ github.com/pingcap/tidb/executor.(*recordSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/executor/adapter.go:126\ngithub.com/pingcap/tidb/server.(*tidbResultSet).Next\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/driver_tidb.go:386\ngithub.com/pingcap/tidb/server.(*clientConn).writeChunksWithFetchSize\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:1459\ngithub.com/pingcap/tidb/server.(*clientConn).writeResultset\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:1376\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmtFetch\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn_stmt.go:243\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:921\ngithub.com/pingcap/tidb/server.(*clientConn).Run\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/conn.go:715\ngithub.com/pingcap/tidb/server.(*Server).onConn\ \t/home/jenkins/agent/workspace/tidb_v4.0.3/go/src/github.com/pingcap/tidb/server/server.go:415\ runtime.goexit\ \t/usr/local/go/src/runtime/asm_amd64.s:1357\ SELECT * FROM information_schema.key_column_usage”]

@Tao
您好,请问有创建外键的语句吗,如果有,麻烦提供下建表语句。

这个是系统表,不是我手动创建的

我是指其他的表,可以的麻烦提供下 ddl history。
curl http://{TiDBIP}:10080/ddl/history

执行 curl http://{TiDBIP}:10080/ddl/history 三分钟都没出结果

curl http://{TiDBIP}:{TIDB_status_port}/ddl/history > tidb_ddl_history.txt
主要大括号中地址和 port 的变更,将附件压缩上传即可

curl http://10.10.5.29:10080/ddl/history
执行了4分钟 没出结果
返回了 curl: (52) Empty reply from server

再试试这个
curl http://{TiDBIP}:10080/ddl/history?limit=10000 > tidb_ddl_history.txt

完了,执行这个查询的时候,服务器挂了

麻烦上传下 tidb 的日志,以及检查下 tidb_stderr.log