暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

表分区删除后,执行查询语句日志报错partition does not exist

原创 qi_yu 2024-12-25
89

发现版本

3.0.5 4db7019a

问题概述

背景:
增删分区是00:05:22-00:05:28,报错是从00:05:22开始持续到06:00左右,报错全部为同一个表分区的oid,该表分区oid在pg_partition表中未查询到
表结构:
image.png
日志报错:
image.png

问题原因

opengauss在事务中删除表分区后不提交,在另一会话中查询表分区的数据,提交删除表分区的语句后会报错。

修复方案

在PartitionOpenWithPartitionno提前判断newpartOid是否合法,并返回NULL而非报错;在执行层跳过删除的分区表。

复现用例

  • 必现用例一:
    会话一执行:
reset current_schema;
drop schema sdsapp cascade;
create schema sdsapp;
set current_schema = sdsapp;
CREATE SEQUENCE sdsapp.sup_scheduler_single_task_rcm_id_seq
INCREMENT BY 1
MINVALUE 1
MAXVALUE 9223372036854775807;
CREATE TABLE IF NOT EXISTS sdsapp.sup_scheduler_single_task_rcm (
id INT4 NOT NULL DEFAULT nextval('sup_scheduler_single_task_rcm_id_seq'::regclass),
seq_num VARCHAR(32) NOT NULL,
unique_id VARCHAR(200) NOT NULL,
request_no VARCHAR(60),
task_num VARCHAR(60),
trans_seq_num VARCHAR(32),
req_type VARCHAR(2) NOT NULL,
file_code VARCHAR(3) NOT NULL,
td_code VARCHAR(500),
sys_id VARCHAR(5),
order_tag VARCHAR(5),
order_type VARCHAR(5),
file_name VARCHAR(100) NOT NULL,
file_status CHAR(1),
ecif_status CHAR(1),
ecif_resultreason VARCHAR(100),
main_cate VARCHAR(2),
acct_no VARCHAR(50),
open_date VARCHAR(50),
result_reason VARCHAR(255),
qry_time VARCHAR(50),
start_tm VARCHAR(50),
end_tm VARCHAR(50),
create_time TIMESTAMP NOT NULL,
update_time TIMESTAMP,
host_name VARCHAR(255),
sum_total INT4,
batch_tag VARCHAR(255),
data_porcess VARCHAR(100),
history_count INT8,
history_count_distinct INT8,
history_elapsed_time VARCHAR(100),
realtime_count INT8,
real_time_elapsed_time VARCHAR(100),
data_process_elapsed_time VARCHAR(100),
total_elapsed_time VARCHAR(100),
version INT4,
remark1 VARCHAR(255),
remark2 VARCHAR(255),
remark3 VARCHAR(255),
remark4 VARCHAR(255),
remark5 VARCHAR(255),
remark6 VARCHAR(255),
remark7 VARCHAR(255),
remark8 VARCHAR(255),
remark9 VARCHAR(255),
remark10 VARCHAR(255),
remark11 VARCHAR(255),
remark12 VARCHAR(255),
remark13 VARCHAR(255),
remark14 VARCHAR(255),
remark15 VARCHAR(255)
)
WITH(ORIENTATION = ROW, COMPRESSION = NO)
PARTITION BY RANGE (create_time)
(
PARTITION part_20240328 VALUES LESS THAN ('2024-03-28'),
PARTITION part_20240329 VALUES LESS THAN ('2024-03-29'),
PARTITION part_20240330 VALUES LESS THAN ('2024-03-30'));
alter table sup_scheduler_single_task_rcm add CONSTRAINT sup_scheduler_single_task_rcm_prikey PRIMARY KEY (id,create_time);
CREATE unique INDEX sup_scheduler_single_task_rcm_unique_id_new ON sdsapp.sup_scheduler_single_task_rcm(unique_id ASC,create_time ASC) local;
CREATE unique INDEX sup_scheduler_single_task_rcm_id_new ON sdsapp.sup_scheduler_single_task_rcm(id ASC,create_time ASC) local;
CREATE INDEX sup_scheduler_single_task_rcm_order_tag_create_time ON sdsapp.sup_scheduler_single_task_rcm(order_tag ASC,create_time ASC) local;
CREATE INDEX sup_scheduler_single_task_rcm_seq_num_file_status ON sdsapp.sup_scheduler_single_task_rcm(seq_num ASC,file_status ASC) local;
insert into
sup_scheduler_single_task_rcm(id,seq_num,unique_id,request_no,task_num,trans_seq_num,req_type,
file_code,file_name,create_time, file_status) values (10046631,'81701202406280014033934817393401',
'81701202406280014033934817393401_3010020240XB_QRY6283308046985_3010020240628330804698500001_51000000000035276680','3010020240XB_QRY6283308046985',
'3010020240628330804698500001','D5720240628093902106001004663101','02','106','81701202406280014033934817393401_DEP_00001','2024-03-28 09:39:12.158', '2');
select
ID,SEQ_NUM,UNIQUE_ID,REQUEST_NO,TASK_NUM,TRANS_SEQ_NUM,REQ_TYPE,FILE_CODE,TD_CODE,SYS_ID,ORDER_TAG,ORDER_TYPE,FILE_NAME,FILE_STATUS,ECIF_STATUS,ECIF_RESULTREASON,MAIN_CATE,ACCT_NO,OPEN_DATE,RESULT_REASON,QRY_TIME,START_TM,END_TM,CREATE_TIME,UPDATE_TIME,HOST_NAME,SUM_TOTAL,BATCH_TAG,DATA_PORCESS,HISTORY_COUNT,HISTORY_COUNT_DISTINCT,HISTORY_ELAPSED_TIME,REALTIME_COUNT,REAL_TIME_ELAPSED_TIME,DATA_PROCESS_ELAPSED_TIME,TOTAL_ELAPSED_TIME,VERSION,REMARK1,REMARK2,REMARK3,REMARK4,REMARK5,REMARK6,REMARK7,REMARK8,REMARK9,REMARK10,REMARK11,REMARK12,REMARK13,REMARK14,REMARK15
from
sup_scheduler_single_task_rcm
as c
WHERE
c.FILE_STATUS='2'
and c.SEQ_NUM='81701202406280014033934817393401'
and c.REQUEST_NO='3010020240XB_QRY6283308046985'
and c.TASK_NUM='3010020240628330804698500001'
order by ORDER_TAG,CREATE_TIME ASC LIMIT 1;
begin;
alter table sup_scheduler_single_task_rcm drop partition part_20240329;
复制

会话2执行:

select
ID,SEQ_NUM,UNIQUE_ID,REQUEST_NO,TASK_NUM,TRANS_SEQ_NUM,REQ_TYPE,FILE_CODE,TD_CODE,SYS_ID,ORDER_TAG,ORDER_TYPE,FILE_NAME,FILE_STATUS,ECIF_STATUS,ECIF_RESULTREASON,MAIN_CATE,ACCT_NO,OPEN_DATE,RESULT_REASON,QRY_TIME,START_TM,END_TM,CREATE_TIME,UPDATE_TIME,HOST_NAME,SUM_TOTAL,BATCH_TAG,DATA_PORCESS,HISTORY_COUNT,HISTORY_COUNT_DISTINCT,HISTORY_ELAPSED_TIME,REALTIME_COUNT,REAL_TIME_ELAPSED_TIME,DATA_PROCESS_ELAPSED_TIME,TOTAL_ELAPSED_TIME,VERSION,REMARK1,REMARK2,REMARK3,REMARK4,REMARK5,REMARK6,REMARK7,REMARK8,REMARK9,REMARK10,REMARK11,REMARK12,REMARK13,REMARK14,REMARK15
from
sup_scheduler_single_task_rcm
as c
WHERE
c.FILE_STATUS='2'
and c.SEQ_NUM='81701202406280014033934817393401'
and c.REQUEST_NO='3010020240XB_QRY6283308046985'
and c.TASK_NUM='3010020240628330804698500001'
order by ORDER_TAG,CREATE_TIME ASC LIMIT 1;
复制

执行后,会话2会卡住
会话一执行commit后修改前会话2会报错

  • 必现用例二:
    会话一执行:
drop table t1;
CREATE TABLE IF NOT EXISTS t1 (
create_time TIMESTAMP NOT NULL
)
WITH(ORIENTATION = ROW, COMPRESSION = NO)
PARTITION BY RANGE (create_time)
(
PARTITION part_20240328 VALUES LESS THAN ('2024-03-28'),
PARTITION part_20240329 VALUES LESS THAN ('2024-03-29'),
PARTITION part_20240330 VALUES LESS THAN ('2024-03-30'));
insert into t1 values('2024-03-28 09:39:12.158');
begin;
alter table t1 drop partition part_20240329;
复制

会话2执行

select * from t1;
复制

执行后,会话2会卡住
会话一执行commit后修改前会话2会报错,修改后不会报错

修复版本

3.0.6

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论