已关闭
[Bug]: 【测试类型:功能测试】打开动态采样参数,select *from空表会卡住 #214
jiangyan创建于  6月5日关闭于  20 天前
jiangyan
jiangyan成员
6月5日 创建

测试类型

SQL功能

测试版本

7.0.0LTS

问题描述

打开动态采样参数,select *from空表会卡住

操作系统和硬件信息

NAME="openEuler"
VERSION="22.03 (LTS-SP4)"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 (LTS-SP4)"
ANSI_COLOR="0;31"

测试环境

企业版主备

被测功能

动态采样

预置条件

操作步骤

ALTER SYSTEM SET _opt_cbo_stat_sampling_level = 1;
drop table test_3;
create table test_3 (a int);
select *from test_3;

预期输出

Succeed

实际输出

SQL卡住

日志信息

绿区机器
堆栈路径/home/ograc
日志路径/data/ograc_install/ograc/log/ograc/run

提单组织

测试团队

测试代码

likedislike
jiangyanjiangyan成员
6月5日 添加了label:bug
jiangyanjiangyan成员
6月5日 关联了看板:openGauss 7.0.0-LTS
opengauss_bot
opengauss_bot成员
6月5日 评论:

This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.

likedislike
opengauss_botopengauss_bot成员
6月5日 添加了label:sig/StorageEngine
opengauss_botopengauss_bot成员
6月5日 将 TestManager 设为负责人
opengauss_bot
opengauss_bot成员
6月5日 评论:

Welcome To openGauss Community

Hey @jiangyan_jack , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: StorageEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @ywzq1161327784 ,
and any of the committers: @CityYard, @libiao2024, @lijieac, @theothersideofsea, @wang_bowen, @weithu, @xiong_xjun, @yuanyazhi .

likedislike
jiangyanjiangyan成员
6月5日 将 muyulinzhong 设为负责人,移除负责人 TestManager
muyulinzhongmuyulinzhong成员
6月8日 将 hejiahuan11 设为负责人
muyulinzhongmuyulinzhong成员
6月8日 移除了负责人 muyulinzhong
hejiahuan11
hejiahuan11成员
6月20日 评论:
ogsql / as sysdba -q -c "SELECT SID, EVENT#, EVENT, WAIT_CLASS, STATE, WAIT_TIME_MIRCO, SECONDS_IN_WAIT FROM SYS.DV_SESSION_WAITS WHERE STATE = 'WAITING';"

connected.


SQL> 
SID          EVENT#       EVENT                                                            WAIT_CLASS                                                       STATE                                                            WAIT_TIME_MIRCO      SECONDS_IN_WAIT     
------------ ------------ ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- -------------------- --------------------
48           8            log file sync                                                    Commit                                                           WAITING                                                          555                  0                   

1 rows fetched.

log file sync卡住
卡死的线程堆栈间歇性的会出现如下两种,3453435为Ogracd进程号

for tid in /proc/3453435/task/*/; do     tid=$(basename $tid);     state=$(cat /proc/3453435/task/$tid/stat 2>/dev/null | awk '{print $3}');     wchan=$(cat /proc/3453435/task/$tid/wchan 2>/dev/null);     if [ "$state" = "D" ]; then         echo "=== TID: $tid STATE: $state WCHAN: $wchan ===";         cat /proc/3453435/task/$tid/stack 2>/dev/null | head -5;         echo "";     fi; done
=== TID: 3457073 STATE: D WCHAN: futex_wait_queue_me ===
[<0>] __switch_to+0xf0/0x158
[<0>] __blkdev_direct_IO_simple+0x1a8/0x370
[<0>] blkdev_direct_IO+0x38c/0x400
[<0>] generic_file_direct_write+0x94/0x1a0
[<0>] __generic_file_write_iter+0xb0/0x1c8

for tid in /proc/3453435/task/*/; do     tid=$(basename $tid);     state=$(cat /proc/3453435/task/$tid/stat 2>/dev/null | awk '{print $3}');     wchan=$(cat /proc/3453435/task/$tid/wchan 2>/dev/null);     if [ "$state" = "D" ]; then         echo "=== TID: $tid STATE: $state WCHAN: $wchan ===";         cat /proc/3453435/task/$tid/stack 2>/dev/null | head -5;         echo "";     fi; done
=== TID: 3457073 STATE: D WCHAN: __blkdev_direct_IO_simple ===
[<0>] __switch_to+0xf0/0x158
[<0>] futex_wait_queue_me+0xd4/0x158
[<0>] futex_wait+0xf4/0x230
[<0>] do_futex+0x440/0x8c8
[<0>] __arm64_sys_futex+0x13c/0x188

同时,dmesg -T | tail -100有回显如下

[Sat Jun 20 14:17:39 2026] sd 6:0:8:0: reservation conflict
[Sat Jun 20 14:17:39 2026] sd 6:0:10:0: reservation conflict
[Sat Jun 20 14:17:39 2026] sd 6:0:11:0: reservation conflict
[Sat Jun 20 14:28:05 2026] systemd-fstab-generator[3563746]: Failed to create unit file /run/systemd/generator/usr1.mount, as it already exists. Duplicate entry in /etc/fstab?
[Sat Jun 20 14:28:05 2026] systemd-rc-local-generator[3563750]: /etc/rc.d/rc.local is not marked executable, skipping.

[6:0:8:0][6:0:10:0][6:0:11:0]分别是三个dss disk

__blkdev_direct_IO_simple,说明请求已经下发到块设备层,正在等待磁盘返回。
待进一步分析确认修改方式

likedislike
hejiahuan11
hejiahuan11成员
7月21日 评论:

7.21
dmesg并没有任何输出,但该问题仍然复现,发现ogracd的stack中D状态可能由于futex_wait导致
[<0>] futex_wait_queue_me+0xd4/0x158
[<0>] futex_wait+0xf4/0x230
[<0>] do_futex+0x440/0x8c8

空表的动态采样会走进stats_gather_empty_table,会启动自治事务更新sys_columns、sys_index、sys_tablepart、sys_table,自治事务提交会产生redo

然后在ogracd的多个dbwr_proc线程中看到显示在libpthread的锁等待位
暂时怀疑是该场景稳定引起死锁,计划尝试debug环境复现,确认一下锁类型和拥有者、等待链

likedislike
hejiahuan11hejiahuan11成员
22 天前 关联了pull request:修改开启动态采样后,查询空单表卡死的问题
hejiahuan11hejiahuan11成员
22 天前 issue状态由 待办的 改变为 已完成
hejiahuan11
hejiahuan11成员
22 天前 评论:

自验证:
image.png

likedislike
hejiahuan11hejiahuan11成员
22 天前 issue状态由 已完成 改变为 待回归
jiangyan
jiangyan成员
20 天前 评论:

回归日期:2026年7月30日
回归版本:openGauss7.0.0LTS
验证截图
image.png

likedislike
jiangyanjiangyan成员
20 天前 issue状态由 待回归 改变为 已验收
jiangyanjiangyan成员
20 天前 关闭了 issue