为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【TiDB 版本】
v5.0.1
【问题描述】
Wordpress 系统,发现在执行下面sql时,必然会出错。
执行explain也同样会报错。
烦请看看是什么问题,如何解决。
谢谢。
详细如下:
SQL:
SELECT wp_6_comments.* FROM wp_6_comments JOIN wp_6_posts ON ( wp_6_comments.comment_post_ID = wp_6_posts.ID ) WHERE ( post_status = ‘publish’ OR ( post_status = ‘inherit’ AND post_type = ‘attachment’ ) ) AND comment_approved = ‘1’ ORDER BY comment_date_gmt DESC LIMIT 10;
explain SELECT wp_6_comments.* FROM wp_6_comments JOIN wp_6_posts ON ( wp_6_comments.comment_post_ID = wp_6_posts.ID ) WHERE ( post_status = ‘publish’ OR ( post_status = ‘inherit’ AND post_type = ‘attachment’ ) ) AND comment_approved = ‘1’ ORDER BY comment_date_gmt DESC LIMIT 10;
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference
TABLE:
| wp_6_comments | CREATE TABLE wp_6_comments
(
comment_ID
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
comment_post_ID
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
comment_author
tinytext COLLATE utf8mb4_unicode_ci NOT NULL,
comment_author_email
varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_author_url
varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_author_IP
varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_date
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
comment_date_gmt
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
comment_content
text COLLATE utf8mb4_unicode_ci NOT NULL,
comment_karma
int(11) NOT NULL DEFAULT ‘0’,
comment_approved
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘1’,
comment_agent
varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_type
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_parent
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
user_id
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
PRIMARY KEY (comment_ID
) /*T![clustered_index] CLUSTERED */,
KEY comment_post_ID
(comment_post_ID
),
KEY comment_approved_date_gmt
(comment_approved
,comment_date_gmt
),
KEY comment_date_gmt
(comment_date_gmt
),
KEY comment_parent
(comment_parent
),
KEY comment_author_email
(comment_author_email
(10))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=15;
| wp_6_posts | CREATE TABLE wp_6_posts
(
ID
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_author
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
post_date
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
post_date_gmt
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
post_content
longtext COLLATE utf8mb4_unicode_ci NOT NULL,
post_title
text COLLATE utf8mb4_unicode_ci NOT NULL,
post_excerpt
text COLLATE utf8mb4_unicode_ci NOT NULL,
post_status
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘publish’,
comment_status
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘open’,
ping_status
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘open’,
post_password
varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
post_name
varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
to_ping
text COLLATE utf8mb4_unicode_ci NOT NULL,
pinged
text COLLATE utf8mb4_unicode_ci NOT NULL,
post_modified
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
post_modified_gmt
datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
post_content_filtered
longtext COLLATE utf8mb4_unicode_ci NOT NULL,
post_parent
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
guid
varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
menu_order
int(11) NOT NULL DEFAULT ‘0’,
post_type
varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘post’,
post_mime_type
varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
comment_count
bigint(20) NOT NULL DEFAULT ‘0’,
PRIMARY KEY (ID
) /*T![clustered_index] CLUSTERED */,
KEY post_name
(post_name
(191)),
KEY type_status_date
(post_type
,post_status
,post_date
,ID
),
KEY post_parent
(post_parent
),
KEY post_author
(post_author
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=153193
tidb.log如下
[ERROR] [conn.go:736] ["connection running loop panic"] [conn=364767] [lastSQL="SELECT wp_6_comments.* FROM wp_6_comments JOIN wp_
6_posts ON ( wp_6_comments.comment_post_ID = wp_6_posts.ID ) WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comme
nt_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 10"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="goroutine 23959730 [ru
nning]:\
github.com/pingcap/tidb/server.(*clientConn).Run.func1(0x4004660, 0xc0704e9b60, 0xc155782600)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linu
x-amd/go/src/github.com/pingcap/tidb/server/conn.go:734 +0xee\
panic(0x3597a40, 0x59111a0)\
\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\
github.com/pingcap/tidb
/statistics.(*HistColl).Selectivity(0xc07201fe40, 0x405dc80, 0xc06e6112c0, 0xc072031a80, 0x1, 0x1, 0xc072058b70, 0x6, 0x6, 0x0, ...)\
\t/home/jenkins/agent/workspac
e/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/statistics/selectivity.go:245 +0x999\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).constru
ctInnerTableScanTask(0xc047d61880, 0xc07040b900, 0xc072076960, 0xc15dd6fe58, 0x1, 0x1, 0x0, 0x0, 0x3fefffffffffffff, 0x0, ...)\
\t/home/jenkins/agent/workspace/opti
mization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:915 +0x753\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).
buildIndexJoinInner2TableScan(0xc047d61880, 0xc0720a6310, 0xc07040b900, 0xc15dd6fe50, 0x1, 0x1, 0xc15dd6fe48, 0x1, 0x1, 0x0, ...)\
\t/home/jenkins/agent/workspace/o
ptimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:750 +0x31c\
github.com/pingcap/tidb/planner/core.(*LogicalJoi
n).getIndexJoinByOuterIdx(0xc047d61880, 0xc0720a6310, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingc
ap/tidb/planner/core/exhaust_physical_plans.go:655 +0x325\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).tryToGetIndexJoin(0xc047d61880, 0xc0720a6310, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:1563 +0xa74\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).exhaustPhysicalPlans(0xc047d61880, 0xc0720a6310, 0xc0720a24e0, 0x18, 0x5f98a00, 0xc07209c650)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:1695 +0x334\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc047d618a0, 0xc0720a60e0, 0x598c388, 0x0, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:310 +0x1d5\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).enumeratePhysicalPlans4Task(0xc072021ba0, 0xc07209b020, 0x6, 0x6, 0xc07202bf80, 0xc07209c600, 0x598c388, 0x10, 0x36b3440, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:213 +0x70d\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc072021ba0, 0xc07202bf10, 0x598c388, 0x0, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:343 +0x32f\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).enumeratePhysicalPlans4Task(0xc071757ec0, 0xc07209c620, 0x1, 0x1, 0xc07202bea0, 0xc07202be00, 0xc0cca83160, 0x68, 0x37db3c0, 0xc070e50300, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:213 +0x70d\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc071757ec0, 0xc07202be30, 0xc0cca83160, 0x0, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:343 +0x32f\
github.com/pingcap/tidb/planner/core.physicalOptimize(0x40594a0, 0xc071757ea0, 0xc0cca83160, 0x4058fa0, 0xc072090000, 0x40594a0, 0xc071757ea0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:224 +0x131\
github.com/pingcap/tidb/planner/core.DoOptimize(0x4004660, 0xc0720587b0, 0x405dc80, 0xc06e6112c0, 0x18a2, 0x40594a0, 0xc071757ea0, 0x0, 0x0, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingc"]
[ERROR] [conn.go:736] ["connection running loop panic"] [conn=1469] [lastSQL="explain SELECT wp_6_comments.* FROM wp_6_comments JO
IN wp_6_posts ON ( wp_6_comments.comment_post_ID = wp_6_posts.ID ) WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) )"] [
err="runtime error: invalid memory address or nil pointer dereference"] [stack="goroutine 412638 [running]:\
github.com/pingcap/tidb/server.(*clientConn).Run.func1(
0x4004660, 0xc0f86d8c90, 0xc17bcf4d00)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:734 +0xee\
p
anic(0x3597a40, 0x59111a0)\
\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\
github.com/pingcap/tidb/statistics.(*HistColl).Selectivity(0xc012ef7500, 0x405dc80, 0xc
011e23040, 0xc0090ecb60, 0x1, 0x1, 0xc01a73d920, 0x6, 0x6, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/ti
db/statistics/selectivity.go:245 +0x999\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).constructInnerTableScanTask(0xc17533bdc0, 0xc00dc45900, 0xc012eb7b80, 0
xc1b0fa0790, 0x1, 0x1, 0x0, 0x0, 0x3fefffffffffffff, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/pla
nner/core/exhaust_physical_plans.go:915 +0x753\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).buildIndexJoinInner2TableScan(0xc17533bdc0, 0xc0957f3f10, 0xc00d
c45900, 0xc1b0fa0788, 0x1, 0x1, 0xc1b0fa0780, 0x1, 0x1, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/
planner/core/exhaust_physical_plans.go:750 +0x31c\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).getIndexJoinByOuterIdx(0xc17533bdc0, 0xc0957f3f10, 0x0, 0x0,
0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:655 +0x325\
githu
b.com/pingcap/tidb/planner/core.(*LogicalJoin).tryToGetIndexJoin(0xc17533bdc0, 0xc0957f3f10, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build
-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/exhaust_physical_plans.go:1563 +0xa74\
github.com/pingcap/tidb/planner/core.(*LogicalJoin).exhaustPhysic
alPlans(0xc17533bdc0, 0xc0957f3f10, 0xc0d0053c60, 0x18, 0x5f98a00, 0xc0090ed520)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.co
m/pingcap/tidb/planner/core/exhaust_physical_plans.go:1695 +0x334\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc17533bde0, 0xc0957f3b90,
0x598c388, 0x0, 0x0, 0x0, 0x0, 0x0)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go
:310 +0x1d5\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).enumeratePhysicalPlans4Task(0xc0138c6480, 0xc0090ed510, 0x1, 0x1, 0xc0957f3810, 0xc0957f3400, 0
xc03ce43578, 0x68, 0x37db3c0, 0xc07e6e5b00, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find
_best_task.go:213 +0x70d\
github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc0138c6480, 0xc0957f3490, 0xc03ce43578, 0x0, 0x0, 0x0, 0x0, 0x0)\
\
t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/find_best_task.go:343 +0x32f\
github.com/pingcap/tidb/p
lanner/core.physicalOptimize(0x40594a0, 0xc0138c6460, 0xc03ce43578, 0x40594a0, 0xc0138c6460, 0x40594a0, 0xc0138c6460, 0x0)\
\t/home/jenkins/agent/workspace/optimiza
tion-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:224 +0x131\
github.com/pingcap/tidb/planner/core.DoOptimize(0x4004660, 0xc01a73d4
d0, 0x405dc80, 0xc011e23040, 0x10a2, 0x40594a0, 0xc0138c6460, 0x0, 0x0, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.c
om/pingcap/tidb/planner/core/optimizer.go:143 +0x13a\
github.com/pingcap/tidb/planner.optimize(0x4004660, 0xc01a73d4d0, 0x405dc80, 0xc011e23040, 0x40233e0, 0xc12803
6900, 0x404fae0, 0xc00dffed20, 0x0, 0x0, ...)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go:
288 +0x66c\
github.com/pingcap/tidb/planner.Optimize(0x4004660, 0xc01a73d4d0, 0x405dc80, 0xc011e23040, 0x40233e0, 0xc128036900, 0x404fae0, 0xc00dffed20, 0x0, 0x0, .
..)\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go"]
若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。