已关闭
[Bug]: 分区表DDL和UPSERT语法并发执行,出现引用计数泄漏 #8420
totaj创建于  8月21日关闭于  9月11日
totaj
totaj成员
8月21日 创建

测试类型

SQL功能

测试版本

7.0.0LTS

问题描述

操作系统和硬件信息

openEuler release 20.03 (LTS-SP1)
Linux opengauss36 4.19.90-2109.1.0.0108.oe1.aarch64 #1 SMP Mon Sep 6 03:51:48 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

测试环境

企业版单机

被测功能

预置条件

操作步骤

生成基础数据:

drop table if exists tmp_t;
CREATE TABLE tmp_t
(
 a date primary key,
 b int ,
 c VARCHAR2 ( 30 )
)
PARTITION BY RANGE (a) INTERVAL ('1 month')
 (
 PARTITION p1 VALUES LESS THAN ('2021-01-31 23:59:59'),
 PARTITION p2 VALUES LESS THAN ('2021-02-28 23:59:59'),
 PARTITION p3 VALUES LESS THAN ('2021-03-31 23:59:59'),
 PARTITION p4 VALUES LESS THAN ('2021-04-30 23:59:59')
 )
 ENABLE ROW MOVEMENT;

drop table if exists interval_part_t;
CREATE TABLE interval_part_t (like tmp_t including all);

create index i_interval_part_t on interval_part_t(a,c) ;
insert into interval_part_t VALUES('2021-03-07 17:00:00',1,'rr'),('2021-02-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-04-07 17:00:00',1,'rr'),('2021-04-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-08-07 17:00:00',1,'dd'),('2021-09-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-05-06 17:00:00',1,'dd'),('2021-10-18 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-05-17 17:00:00',1,1),('2021-10-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-10-17 17:00:00',1,1),('2021-11-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-08-17 17:00:00',1,1),('2021-08-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-09-17 17:00:00',1,1),('2021-10-02 17:00:00',2,1);
insert into interval_part_t VALUES('2021-11-17 17:00:00',1,1),('2023-01-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-12-28 17:00:00',2,1),('2021-11-18 17:00:00',1,1);

测试用例,使用gsql的paralle功能进行并发操作:

\parallel on
alter table interval_part_t merge partitions sys_p2,sys_p4,sys_p5 into partition sys_p5 update global index;
insert into interval_part_t VALUES('2021-11-17 17:00:00',1,1),('2023-01-08 17:00:00',2,1) ON DUPLICATE KEY UPDATE c='zz';
insert into interval_part_t VALUES('2021-12-28 17:00:00',2,1),('2021-11-18 17:00:00',1,1) ON DUPLICATE KEY UPDATE c='zz';
\parallel off

预期输出

  1. 数据插入成功
  2. DDL语句成功执行
  3. 数据未丢失,upsert结果正确,分区正常合并,全局分区索引正常更新
  4. 过程无报错

实际输出

WARNING: fakerel reference leak: fakerel "interval_part_t" not closed
WARNING: partcache reference leak: partition "sys_p5" not closed
WARNING: fakerel reference leak: fakerel "interval_part_t" not closed
WARNING: partcache reference leak: partition "sys_p5" not closed

日志信息

image.png

提单组织

内部开发

测试代码

likedislike
totajtotaj成员
8月21日 添加了label:bug
opengauss_bot
opengauss_bot成员
8月21日 评论:

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成员
8月21日 将 TestManager 设为负责人
opengauss_botopengauss_bot成员
8月21日 添加了label:sig/StorageEngine,sig/AI,sig/CM,sig/CloudNative,sig/SecurityTechnology,sig/SQLEngine
opengauss_bot
opengauss_bot成员
8月21日 评论:

Welcome To openGauss Community

Hey @totaj , 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, AI, CM, CloudNative, SecurityTechnology, SQLEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @Igali, @bihua111, @cailei19, @h_ray, @levy53071, @libiao2024, @lihaixiao, @mrzack, @wangfeihuo, @wuyuechuan, @xiong_xjun, @zhangfengzhi123, @zhangxubo, @zhangzq131, @zjh_hw .

likedislike
totajtotaj成员
8月21日 issue优先级由 无优先级 改变为 次要
totajtotaj成员
8月21日 关联了看板:openGauss 7.0.0-LTS
totajtotaj成员
8月21日 将 ywzq1161327784 设为负责人
totajtotaj成员
8月21日 移除了负责人 TestManager
zjj_sc
zjj_sc成员
8月24日 评论:

/assign

likedislike
opengauss_botopengauss_bot成员
8月24日 将 m0_57849461 设为负责人,移除负责人 ywzq1161327784
此处折叠了16条事件消息 查看更多
l1azzzyl1azzzy成员
9月9日 重新打开了 issue
zjj_sc
zjj_sc成员
9月9日 评论:

原始用例复现:
image.png

子分区用例扩展复现:
image.png

【自验环境】
openEuler 20.03 aarch64,single_node

【转测包】
openGauss7.0.0.B022
git_num: bc72a519

【关联 PR】
PR 9640
Issue 8420

【验证内容】

  1. gpi_merge_upsert_concurrent.sql 执行通过,最终结果为 20|2|2;
  2. 指定分区 UPSERT、普通 UPSERT、COPY、跨分区 UPDATE 执行正常;
  3. gpi_merge_upsert_subpartition.sql 执行通过,最终结果为 1|0|1;
  4. 子分区 UPSERT、COPY、UPDATE、DELETE及父子分区关系查找执行正常;
  5. 并发用例连续执行 20 次,无非预期 ERROR、PANIC、FATAL;
  6. 服务端日志无分区映射错误和 cache 引用泄漏错误。

【自验结果】
通过。

likedislike
wofanzhengwofanzheng成员
9月9日 issue状态由 待办的 改变为 已完成
wofanzhengwofanzheng成员
9月9日 issue状态由 已完成 改变为 待回归
sungang14
sungang14成员
9月11日 评论:

【回归人员】sungang14
【回归日期】2026.9.11
【回归版本】openGauss 7.0.0B022
【回归结论】通过
【回归步骤】
drop table if exists tmp_t;
CREATE TABLE tmp_t
(
a date primary key,
b int ,
c VARCHAR2 ( 30 )
)
PARTITION BY RANGE (a) INTERVAL ('1 month')
(
PARTITION p1 VALUES LESS THAN ('2021-01-31 23:59:59'),
PARTITION p2 VALUES LESS THAN ('2021-02-28 23:59:59'),
PARTITION p3 VALUES LESS THAN ('2021-03-31 23:59:59'),
PARTITION p4 VALUES LESS THAN ('2021-04-30 23:59:59')
)
ENABLE ROW MOVEMENT;

drop table if exists interval_part_t;
CREATE TABLE interval_part_t (like tmp_t including all);

create index i_interval_part_t on interval_part_t(a,c) ;
insert into interval_part_t VALUES('2021-03-07 17:00:00',1,'rr'),('2021-02-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-04-07 17:00:00',1,'rr'),('2021-04-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-08-07 17:00:00',1,'dd'),('2021-09-08 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-05-06 17:00:00',1,'dd'),('2021-10-18 17:00:00',2,'dd');
insert into interval_part_t VALUES('2021-05-17 17:00:00',1,1),('2021-10-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-10-17 17:00:00',1,1),('2021-11-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-08-17 17:00:00',1,1),('2021-08-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-09-17 17:00:00',1,1),('2021-10-02 17:00:00',2,1);
insert into interval_part_t VALUES('2021-11-17 17:00:00',1,1),('2023-01-08 17:00:00',2,1);
insert into interval_part_t VALUES('2021-12-28 17:00:00',2,1),('2021-11-18 17:00:00',1,1);

\parallel on
alter table interval_part_t merge partitions sys_p2,sys_p4,sys_p5 into partition sys_p5 update global index;
insert into interval_part_t VALUES('2021-11-17 17:00:00',1,1),('2023-01-08 17:00:00',2,1) ON DUPLICATE KEY UPDATE c='zz';
insert into interval_part_t VALUES('2021-12-28 17:00:00',2,1),('2021-11-18 17:00:00',1,1) ON DUPLICATE KEY UPDATE c='zz';
\parallel off

image.png
image.png
image.png

likedislike
sungang14sungang14成员
9月11日 issue状态由 待回归 改变为 已验收
sungang14sungang14成员
9月11日 关闭了 issue
zjj_sc
zjj_sc成员
21 天前 评论:

【转测日期】2026-10-10
【转测包】8.0.0-RC1.B001 目录,实际内核版本:7.0.0 build 6a41b1ba
【验证内容】issue #8420 原始并发用例
【结论】通过。数据保留 20 行,4 行 UPSERT 更新正确,分区合并成功,全局索引有效,无引用计数泄漏告警。
image.png

likedislike
l1azzzy
l1azzzy成员
15 天前 评论:

验收日期:2026-10-16
验收版本:8.0.0-RC1.B002
验收结论:验收通过
image.png

likedislike
zjj_sczjj_sc成员
9 天前 关联了pull request:[6.0.0] 回合 PR #9640:修复并发 DDL 与 UPSERT 导致的分区缓存引用泄漏