v7.5.3 runtime error: index out of range [0] with length 0

Bug 反馈
清晰准确地描述您发现的问题,提供任何可能复现问题的步骤有助于研发同学及时处理问题
【 TiDB 版本】v7.5.3

【看到的非预期行为】

sql如下

EXPLAIN
SELECT
	CONCAT(a.ad_id, '') ad_id,
	a.`name` ad_name,
	CONCAT(a.advertiser_id, '') advertiser_id,
	a.`status`,
	a.opt_status,
	b.`name` advertiser_name,
	e.id customer_id,
	e.customer_short_name
FROM
	Synads_Qc_Ad_Detail a
JOIN mbg_core.qc_advertiser b ON a.advertiser_id = b.advertiser_id
JOIN mbg_core.emarbox_project c ON c.project_id = b.project_id
JOIN mbg_core.yxt_finance_customer_entity d ON d.id = c.pig_advertiser_id
JOIN mbg_core.yxt_finance_customer e ON e.id = d.customer_id
WHERE
	1 = 1
AND a.advertiser_id IN (
	SELECT
		b.platform_account_id advertiser_id
	FROM
		(
			SELECT
				a.project_id
			FROM
				mbg_core.tb_agent_user_project a
			WHERE
				a.user_id = 103680
		) a
	JOIN (
		SELECT
			b.project_id,
			b.platform_account_id
		FROM
			mbg_core.emarbox_project b
		WHERE
			b.deleted = 0
		AND b.media_id = 6
	) b ON a.project_id = b.project_id
	WHERE
		1 = 1
	UNION
		SELECT
			a.advertiser_id
		FROM
			mbg_core.qc_advertiser a
		JOIN (
			SELECT
				b.project_id,
				b.pig_advertiser_id
			FROM
				mbg_core.emarbox_project b
			WHERE
				b.media_id = 6
			AND b.deleted = 0
		) b ON a.project_id = b.project_id
		JOIN mbg_core.yxt_finance_customer_entity c ON c.id = b.pig_advertiser_id
		JOIN mbg_core.yxt_finance_customer d ON d.id = c.customer_id
		WHERE
			d.id IN (
				SELECT
					a.customer_id
				FROM
					mbg_core.tb_agent_user_customer a
				WHERE
					a.user_id =103680
			)
)
AND a.advertiser_id IN (1779611088864333);

如果去掉最后一行的AND内容查询就正常,或者把mbg_core.emarbox_project 的tiflash 副本数去掉也正常

看起来是 bug。最好提供个 plan replayer 本地能 debug 看看 :thinking:

最好提供个 plan replayer 本地能 debug 看看。

或者提供一下最小的问题复现集

另外,给一下日志里的 panic 日志,里面有问题的堆栈信息

panic 日志,只要涉及到sql 涉及到mbg_core.emarbox_project,走tiflash就会有
panic.txt (22.6 KB)

plan replayer 跑不了

https://github.com/pingcap/tidb/issues/53796

应该是这个问题,在 v8.1.1 里已经修复,至于 v7.5 可能要等一下

1 个赞

有没有临时避免的方式?业务sql大多就是这种类型。现在虽然通过去掉tiflash副本解决,但是响应结果变慢了

重建一下对应的索引,看看是否可以解决问题, 此表是否是分区表,如果是,改为非分区表,看看如何绕过bug问题

补充下表结构
表结构.txt (18.8 KB)

CREATE TABLE `tb_agent_user_project` (
  `user_id` bigint(20) NOT NULL,
  `project_id` int(10) NOT NULL,
  `type` int(1) NOT NULL COMMENT '0: 管理员资源,1:普通用户资源',
  `source_type` int(1) DEFAULT NULL COMMENT '0:权限分配,1:下级同步',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`project_id`,`type`,`user_id`) /*T![clustered_index] NONCLUSTERED */,
  KEY `project_id` (`project_id`),
  KEY `idx_p_user_id` (`user_id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin

planner: do not reset child projection’s schema (#52836) by ti-chi-bot · Pull Request #55109 · pingc

应该是这个问题,已经cherrypick 到 7.5 ,下次发版本解决

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