提交 27f58dd0 编写于 作者: D Dhanashree Kashid 提交者: Heikki Linnakangas

Update QueryFinishPending test for SharedInputScan

The intent of these tests is to test fault injection for plans with
SharedInputScan over a Sort. While the planner currnetly generates a
SharedInputScan for the window functions, after the window functions
rewrite we're working on, it will now.

To fulfill the intent; change the query to use WITH clause and ORDER BY
such that Planner generated SharedInputScan over a Sort node.
Signed-off-by: NEkta Khanna <ekhanna@pivotal.io>
上级 c8dd0c60
......@@ -51,6 +51,10 @@ insert into testsisc select i, i % 1000, i % 100000, i % 75 from
set gp_resqueue_print_operator_memory_limits=on;
set statement_mem='2MB';
set gp_enable_mk_sort=off;
-- ORCA does not generate SharedInputScan with a Sort node underneath it. For
-- the following query, ORCA disregards the order by inside the cte definition;
-- planner on the other hand does not.
set optimizer=off;
select gp_inject_fault('execshare_input_next', 'reset', 2);
NOTICE: Success:
gp_inject_fault
......@@ -67,13 +71,12 @@ NOTICE: Success:
t
(1 row)
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
count
-------
1
1
with cte as (select i2 from testsisc order by i2)
select * from cte c1, cte c2 limit 2;
i2 | i2
----+----
0 | 0
0 | 0
(2 rows)
select gp_inject_fault('execshare_input_next', 'status', 2);
......@@ -102,13 +105,12 @@ NOTICE: Success:
t
(1 row)
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
count
-------
1
1
with cte as (select i2 from testsisc order by i2)
select * from cte c1, cte c2 limit 2;
i2 | i2
----+----
0 | 0
0 | 0
(2 rows)
select gp_inject_fault('execshare_input_next', 'status', 2);
......
CREATE EXTENSION IF NOT EXISTS gp_inject_fault;
drop table if exists _tmp_table;
NOTICE: table "_tmp_table" does not exist, skipping
create table _tmp_table (i1 int, i2 int, i3 int, i4 int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
insert into _tmp_table select i, i % 100, i % 10000, i % 75 from generate_series(0,99999) i;
-- make sort to spill
set statement_mem="2MB";
set gp_enable_mk_sort=on;
set gp_cte_sharing=on;
select gp_inject_fault('execsort_mksort_mergeruns', 'reset', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
-- set QueryFinishPending=true in sort mergeruns. This will stop sort and set result_tape to NULL
select gp_inject_fault('execsort_mksort_mergeruns', 'finish_pending', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
-- return results although sort will be interrupted in one of the segments
select DISTINCT S from (select row_number() over(partition by i1 order by i2) AS T, count(*) over (partition by i1) AS S from _tmp_table) AS TMP;
s
---
1
(1 row)
select gp_inject_fault('execsort_mksort_mergeruns', 'status', 2);
NOTICE: Success: fault name:'execsort_mksort_mergeruns' fault type:'finish_pending' ddl statement:'' database name:'' table name:'' occurrence:'1' sleep time:'0' fault injection state:'completed' num times hit:'1'
gp_inject_fault
-----------------
t
(1 row)
-- test if shared input scan deletes memory correctly when QueryFinishPending and its child has been eagerly freed,
-- where the child is a Sort node
drop table if exists testsisc;
NOTICE: table "testsisc" does not exist, skipping
create table testsisc (i1 int, i2 int, i3 int, i4 int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
insert into testsisc select i, i % 1000, i % 100000, i % 75 from
(select generate_series(1, nsegments * 50000) as i from
(select count(*) as nsegments from gp_segment_configuration where role='p' and content >= 0) foo) bar;
set gp_resqueue_print_operator_memory_limits=on;
set statement_mem='2MB';
set gp_enable_mk_sort=off;
select gp_inject_fault('execshare_input_next', 'reset', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
-- Set QueryFinishPending to true after SharedInputScan has retrieved the first tuple.
-- This will eagerly free the memory context of shared input scan's child node.
select gp_inject_fault('execshare_input_next', 'finish_pending', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
count
-------
1
1
(2 rows)
select gp_inject_fault('execshare_input_next', 'status', 2);
NOTICE: Success: fault name:'execshare_input_next' fault type:'finish_pending' ddl statement:'' database name:'' table name:'' occurrence:'1' sleep time:'0' fault injection state:'set' num times hit:'0'
gp_inject_fault
-----------------
t
(1 row)
-- test if shared input scan deletes memory correctly when QueryFinishPending and its child has been eagerly freed,
-- where the child is a Sort node and sort_mk algorithm is used
set gp_enable_mk_sort=on;
select gp_inject_fault('execshare_input_next', 'reset', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
-- Set QueryFinishPending to true after SharedInputScan has retrieved the first tuple.
-- This will eagerly free the memory context of shared input scan's child node.
select gp_inject_fault('execshare_input_next', 'finish_pending', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
count
-------
1
1
(2 rows)
select gp_inject_fault('execshare_input_next', 'status', 2);
NOTICE: Success: fault name:'execshare_input_next' fault type:'finish_pending' ddl statement:'' database name:'' table name:'' occurrence:'1' sleep time:'0' fault injection state:'set' num times hit:'0'
gp_inject_fault
-----------------
t
(1 row)
reset gp_enable_mk_sort;
-- Disable faultinjectors
select gp_inject_fault('execsort_mksort_mergeruns', 'reset', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
select gp_inject_fault('execshare_input_next', 'reset', 2);
NOTICE: Success:
gp_inject_fault
-----------------
t
(1 row)
......@@ -29,15 +29,17 @@ insert into testsisc select i, i % 1000, i % 100000, i % 75 from
set gp_resqueue_print_operator_memory_limits=on;
set statement_mem='2MB';
set gp_enable_mk_sort=off;
-- ORCA does not generate SharedInputScan with a Sort node underneath it. For
-- the following query, ORCA disregards the order by inside the cte definition;
-- planner on the other hand does not.
set optimizer=off;
select gp_inject_fault('execshare_input_next', 'reset', 2);
-- Set QueryFinishPending to true after SharedInputScan has retrieved the first tuple.
-- This will eagerly free the memory context of shared input scan's child node.
select gp_inject_fault('execshare_input_next', 'finish_pending', 2);
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
with cte as (select i2 from testsisc order by i2)
select * from cte c1, cte c2 limit 2;
select gp_inject_fault('execshare_input_next', 'status', 2);
......@@ -51,9 +53,8 @@ select gp_inject_fault('execshare_input_next', 'reset', 2);
-- This will eagerly free the memory context of shared input scan's child node.
select gp_inject_fault('execshare_input_next', 'finish_pending', 2);
select COUNT(i2) over(partition by i1)
from testsisc
LIMIT 2;
with cte as (select i2 from testsisc order by i2)
select * from cte c1, cte c2 limit 2;
select gp_inject_fault('execshare_input_next', 'status', 2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册