399 Star 1.4K Fork 1.5K

GVPopenGauss / openGauss-server

 / 详情

gsql补全功能被中断导致内存泄露

已完成
缺陷
创建于  
2024-04-26 18:05

【标题描述】: gsql补全功能被中断导致内存泄露
【测试类型:SQL功能】
【测试版本:6.0.0-RC1】 问题描述

【操作系统和硬件信息】(查询命令: cat /etc/system-release, uname -a):
CentOS Linux release 7.9.2009 (Core)
Linux host 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

【测试环境】(单机/1主x备x级联备): 单机

【被测功能】: vsql表名补全

【测试类型】: 功能测试

【数据库版本】(查询命令: gaussdb -V): gaussdb (openGauss 6.0.0-RC1 build e41aae90) compiled at 2024-04-26 16:32:57 commit 0 last mr debug

【预置条件】: 存在大量表名或者其他能拖慢查询的情况

【操作步骤】(请填写详细的操作步骤):

  1. 使用内存泄漏检查工具运行gsql,并启用readline库
valgrind --leak-check=yes gsql -dpostgres -r
  1. 创建大量前缀相同的表名
CREATE OR REPLACE FUNCTION create_test_tables(num integer)
RETURNS void AS $$
DECLARE
    i integer := 1;
    tableName text;
BEGIN
    -- 循环从1到num,为每一个数字创建一个表
    FOR i IN 1..num LOOP
        -- 拼接表名
        tableName := 'test_' || i;
        -- 使用EXECUTE执行动态SQL语句来创建表
        EXECUTE 'CREATE TABLE ' || tableName || ' (id serial PRIMARY KEY, data text)';
    END LOOP;
END;
$$ LANGUAGE plpgsql;
SELECT create_test_tables(10000);
  1. 输入表名共同前缀并使用tab键尝试补全,由于表名过多查询会持续两三秒,在此期间ctrl+c中断补全过程
  2. \q退出gsql
    输入图片说明

【预期输出】: 没有与gsql相关的内存泄漏

【实际输出】:
输出结果

【原因分析】:

  1. 这个问题的根因:gsql的handle_sigint函数存在缺陷
  2. 问题推断过程
  3. 还有哪些原因可能造成类似现象
  4. 该问题是否有临时规避措施
  5. 问题解决方案
  6. 预计修复问题时间

【日志信息】(请附上日志文件、截图、coredump信息): 无

【测试代码】: 无

评论 (5)

ZimingZhang 创建了缺陷

Hey @ZimingZhang, Welcome to openGauss Community.
All of the projects in openGauss Community are maintained by @opengauss_bot.
That means the developers can comment below every pull request or issue to trigger Bot Commands.
Please follow instructions at Here to find the details.

Hi @ZimingZhang, please use the command /sig xxx to add a SIG label to this issue.
For example: /sig sqlengine or /sig storageengine or /sig om or /sig ai and so on.
You can find more SIG labels from Here.
If you have no idea about that, please contact with @zhangxubo , @xiangxinyong .

opengauss_bot 添加了
 
sig/infra
标签

Hi @ZimingZhang,
if you want to get quick review about your issue, please contact the owner in first: @zhongjun2 , @ailoooong , @ZhengZhenyu , @Nelson , @xiangxinyong ,
and then any of the maintainers: @zhongjun2
and then any of the committers: @zhangxubo , @邦邦邦邦 , @ailoooong , @xiangrumei , @xiangxinyong
if you have any question, please contact the SIG: Infra.

王恬静 负责人设置为pengjiong
王恬静 关联项目设置为openGauss 6.0.0 community
王恬静 优先级设置为次要

gsql是内核工具责任田,请 @申正 看下

pengjiong 添加协作者pengjiong
pengjiong 负责人pengjiong 修改为申正
pengjiong 取消协作者pengjiong
申正 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(3)
13084139 opengauss bot 1686829535 7416652 ironmanzzm 1688348264
C++
1
https://gitee.com/opengauss/openGauss-server.git
git@gitee.com:opengauss/openGauss-server.git
opengauss
openGauss-server
openGauss-server

搜索帮助