提交 7b87d7b6 编写于 作者: H Heikki Linnakangas

Enhance partition_locking test case to also check locks in segments.

While hacking in this area, at one point I broke the code so that a
partition was not correctly in a segment as it should've been, even though
it was locked in the master. Fortunately, I noticed that in manual testing
before committing, but to prevent such bugs from slipping in in the future,
enhance the 'partition_locking' test to catch that kind of bugs.
上级 6f4986ec
-- Test locking behaviour. When creating, dropping, querying or adding indexes
-- partitioned tables, we want to lock only the master, not the children.
-- start_ignore
create view locktest as
-- Show locks in master and in segments. Because the number of segments
-- in the cluster depends on configuration, we print only summary information
-- of the locks in segments. If a relation is locked only on one segment,
-- we print that as a special case, but otherwise we just print "n segments",
-- meaning the relation is locked on more than one segment.
create or replace view locktest as
select coalesce(
case when relname like 'pg_toast%index' then 'toast index'
when relname like 'pg_toast%' then 'toast table'
else relname end, 'dropped table'),
mode,
locktype from
pg_locks l left outer join pg_class c on (l.relation = c.oid),
pg_database d where relation is not null and l.database = d.oid and
l.gp_segment_id = -1 and
l.relation != 5039 and -- XXX XXX: ignore gp_fault_strategy
d.datname = current_database() order by 1, 3, 2;
-- end_ignore
when relname like 'pg_toast%' then 'toast table'
when relname like 'pg_aoseg%index' then 'aoseg index'
when relname like 'pg_aoseg%' then 'aoseg table'
else relname end, 'dropped table'),
mode,
locktype,
case when l.gp_segment_id = -1 then 'master'
when COUNT(*) = 1 then '1 segment'
else 'n segments' end AS node
from pg_locks l
left outer join pg_class c on (l.relation = c.oid),
pg_database d
where relation is not null
and l.database = d.oid
and (relname <> 'gp_fault_strategy' or relname IS NULL)
and d.datname = current_database()
group by l.gp_segment_id = -1, relation, relname, locktype, mode
order by 1, 3, 2;
-- Partitioned table with toast table
begin;
......@@ -23,18 +35,12 @@ begin;
create table g (i int, t text) partition by range(i)
(start(1) end(10) every(1));
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
-- drop
begin;
drop table g;
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
......@@ -45,9 +51,6 @@ create table g (i int, t text, n numeric)
with (appendonly = true)
partition by list(i)
(values(1), values(2), values(3));
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
begin;
......@@ -58,18 +61,12 @@ insert into g values(1), (2), (3);
insert into g values(1), (2), (3);
insert into g values(1), (2), (3);
insert into g values(1), (2), (3);
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
-- drop
begin;
drop table g;
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
......@@ -79,44 +76,37 @@ create table g (i int, t text) partition by range(i)
begin;
create index g_idx on g(i);
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
-- Force use of the index in the select and delete below. We're not interested
-- in the plan we get, but a seqscan will not lock the index while an index
-- scan will, and we want to avoid the plan-dependent difference in the
-- expected output of this test.
set enable_seqscan=off;
-- test select locking
begin;
select * from g where i = 1;
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
begin;
-- insert locking
insert into g values(3, 'f');
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
-- delete locking
begin;
delete from g where i = 4;
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
-- drop index
begin;
drop table g;
-- start_ignore
-- Known_opt_diff: MPP-20936
-- end_ignore
select * from locktest;
commit;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册