提交 286b431c 编写于 作者: R Richard Guo 提交者: GitHub

Refactor test case for concurrent query cancellation/termination.

This case is to test cancel/terminate queries concurrently while they are 
running or waiting in resource group.
上级 7e268107
......@@ -23,105 +23,35 @@ SET
3:SET ROLE role_concurrency_test;
SET
3&:BEGIN; <waiting ...>
4:SET ROLE role_concurrency_test;
SET
4&:BEGIN; <waiting ...>
5:SET ROLE role_concurrency_test;
SET
5&:BEGIN; <waiting ...>
6:SET ROLE role_concurrency_test;
SET
6&:BEGIN; <waiting ...>
7:SET ROLE role_concurrency_test;
SET
7&:BEGIN; <waiting ...>
8:SET ROLE role_concurrency_test;
SET
8&:BEGIN; <waiting ...>
9:SET ROLE role_concurrency_test;
SET
9&:BEGIN; <waiting ...>
10:SET ROLE role_concurrency_test;
SET
10&:BEGIN; <waiting ...>
11:SET ROLE role_concurrency_test;
SET
11&:BEGIN; <waiting ...>
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> in transaction|rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
(11 rows)
(3 rows)
SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE waiting_reason='resgroup' AND rsgname='rg_concurrency_test';
pg_cancel_backend
-----------------
t
t
t
t
t
t
t
t
t
t
(10 rows)
(2 rows)
1:END;
END
2<: <... completed>
ERROR: canceling statement due to user request
3<: <... completed>
ERROR: canceling statement due to user request
4<: <... completed>
ERROR: canceling statement due to user request
5<: <... completed>
ERROR: canceling statement due to user request
6<: <... completed>
ERROR: canceling statement due to user request
7<: <... completed>
ERROR: canceling statement due to user request
8<: <... completed>
ERROR: canceling statement due to user request
9<: <... completed>
ERROR: canceling statement due to user request
10<: <... completed>
ERROR: canceling statement due to user request
11<: <... completed>
ERROR: canceling statement due to user request
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
(11 rows)
waiting|waiting_reason|current_query|rsgname
-------+--------------+-------------+-------------------
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
(3 rows)
1q: ... <quitting>
2q: ... <quitting>
3q: ... <quitting>
4q: ... <quitting>
5q: ... <quitting>
6q: ... <quitting>
7q: ... <quitting>
8q: ... <quitting>
9q: ... <quitting>
10q: ... <quitting>
11q: ... <quitting>
DROP ROLE role_concurrency_test;
DROP
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -149,59 +79,21 @@ SET
3:SET ROLE role_concurrency_test;
SET
3&:BEGIN; <waiting ...>
4:SET ROLE role_concurrency_test;
SET
4&:BEGIN; <waiting ...>
5:SET ROLE role_concurrency_test;
SET
5&:BEGIN; <waiting ...>
6:SET ROLE role_concurrency_test;
SET
6&:BEGIN; <waiting ...>
7:SET ROLE role_concurrency_test;
SET
7&:BEGIN; <waiting ...>
8:SET ROLE role_concurrency_test;
SET
8&:BEGIN; <waiting ...>
9:SET ROLE role_concurrency_test;
SET
9&:BEGIN; <waiting ...>
10:SET ROLE role_concurrency_test;
SET
10&:BEGIN; <waiting ...>
11:SET ROLE role_concurrency_test;
SET
11&:BEGIN; <waiting ...>
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> in transaction|rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
(11 rows)
(3 rows)
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE waiting_reason='resgroup' AND rsgname='rg_concurrency_test';
pg_terminate_backend
--------------------
t
t
t
t
t
t
t
t
t
t
(10 rows)
(2 rows)
1:END;
END
2<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
......@@ -209,65 +101,17 @@ server closed the connection unexpectedly
before or while processing the request.
3<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
4<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
5<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
6<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
7<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
8<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
9<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
10<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
11<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> in transaction|rg_concurrency_test
waiting|waiting_reason|current_query|rsgname
-------+--------------+-------------+-------------------
f | |<IDLE> |rg_concurrency_test
(1 row)
1q: ... <quitting>
2q: ... <quitting>
3q: ... <quitting>
4q: ... <quitting>
5q: ... <quitting>
6q: ... <quitting>
7q: ... <quitting>
8q: ... <quitting>
9q: ... <quitting>
10q: ... <quitting>
11q: ... <quitting>
DROP ROLE role_concurrency_test;
DROP
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -281,7 +125,7 @@ DROP RESOURCE GROUP rg_concurrency_test;
ERROR: resource group "rg_concurrency_test" does not exist
-- end_ignore
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=5, cpu_rate_limit=20, memory_limit=20);
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=2, cpu_rate_limit=20, memory_limit=20);
CREATE
CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
CREATE
......@@ -291,97 +135,46 @@ SET
2:SET ROLE role_concurrency_test;
SET
2&:SELECT pg_sleep(10000); <waiting ...>
3:SET ROLE role_concurrency_test;
SET
3&:SELECT pg_sleep(10000); <waiting ...>
4:SET ROLE role_concurrency_test;
SET
4&:SELECT pg_sleep(10000); <waiting ...>
5:SET ROLE role_concurrency_test;
SET
5&:SELECT pg_sleep(10000); <waiting ...>
6:SET ROLE role_concurrency_test;
SET
6&:BEGIN; <waiting ...>
7:SET ROLE role_concurrency_test;
SET
7&:BEGIN; <waiting ...>
8:SET ROLE role_concurrency_test;
SET
8&:BEGIN; <waiting ...>
9:SET ROLE role_concurrency_test;
SET
9&:BEGIN; <waiting ...>
10:SET ROLE role_concurrency_test;
SET
10&:BEGIN; <waiting ...>
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+-----------------------+-------------------
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
(10 rows)
(4 rows)
SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE waiting='f' AND rsgname='rg_concurrency_test';
pg_cancel_backend
-----------------
t
t
t
t
t
(5 rows)
(2 rows)
1<: <... completed>
ERROR: canceling statement due to user request
2<: <... completed>
ERROR: canceling statement due to user request
3<: <... completed>
ERROR: canceling statement due to user request
4<: <... completed>
ERROR: canceling statement due to user request
5<: <... completed>
ERROR: canceling statement due to user request
6<: <... completed>
BEGIN
7<: <... completed>
BEGIN
8<: <... completed>
BEGIN
9<: <... completed>
BEGIN
10<: <... completed>
BEGIN
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> |rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
(10 rows)
(4 rows)
1q: ... <quitting>
2q: ... <quitting>
3q: ... <quitting>
4q: ... <quitting>
5q: ... <quitting>
6q: ... <quitting>
7q: ... <quitting>
8q: ... <quitting>
9q: ... <quitting>
10q: ... <quitting>
DROP ROLE role_concurrency_test;
DROP
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -395,7 +188,7 @@ DROP RESOURCE GROUP rg_concurrency_test;
ERROR: resource group "rg_concurrency_test" does not exist
-- end_ignore
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=5, cpu_rate_limit=20, memory_limit=20);
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=2, cpu_rate_limit=20, memory_limit=20);
CREATE
CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
CREATE
......@@ -405,53 +198,26 @@ SET
2:SET ROLE role_concurrency_test;
SET
2&:SELECT pg_sleep(10000); <waiting ...>
3:SET ROLE role_concurrency_test;
SET
3&:SELECT pg_sleep(10000); <waiting ...>
4:SET ROLE role_concurrency_test;
SET
4&:SELECT pg_sleep(10000); <waiting ...>
5:SET ROLE role_concurrency_test;
SET
5&:SELECT pg_sleep(10000); <waiting ...>
6:SET ROLE role_concurrency_test;
SET
6&:BEGIN; <waiting ...>
7:SET ROLE role_concurrency_test;
SET
7&:BEGIN; <waiting ...>
8:SET ROLE role_concurrency_test;
SET
8&:BEGIN; <waiting ...>
9:SET ROLE role_concurrency_test;
SET
9&:BEGIN; <waiting ...>
10:SET ROLE role_concurrency_test;
SET
10&:BEGIN; <waiting ...>
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+-----------------------+-------------------
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
f | |SELECT pg_sleep(10000);|rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
t |resgroup |BEGIN; |rg_concurrency_test
(10 rows)
(4 rows)
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE waiting='f' AND rsgname='rg_concurrency_test';
pg_terminate_backend
--------------------
t
t
t
t
t
(5 rows)
(2 rows)
1<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
......@@ -459,21 +225,6 @@ server closed the connection unexpectedly
before or while processing the request.
2<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
3<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
4<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
5<: <... completed>
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
......@@ -481,31 +232,16 @@ server closed the connection unexpectedly
BEGIN
7<: <... completed>
BEGIN
8<: <... completed>
BEGIN
9<: <... completed>
BEGIN
10<: <... completed>
BEGIN
SELECT * FROM rg_concurrency_view;
waiting|waiting_reason|current_query |rsgname
-------+--------------+---------------------+-------------------
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
f | |<IDLE> in transaction|rg_concurrency_test
(5 rows)
(2 rows)
1q: ... <quitting>
2q: ... <quitting>
3q: ... <quitting>
4q: ... <quitting>
5q: ... <quitting>
6q: ... <quitting>
7q: ... <quitting>
8q: ... <quitting>
9q: ... <quitting>
10q: ... <quitting>
DROP ROLE role_concurrency_test;
DROP
DROP RESOURCE GROUP rg_concurrency_test;
......
......@@ -15,7 +15,7 @@ test: resgroup/resgroup_cpu_rate_limit
test: resgroup/resgroup_alter_memory_spill_ratio
test: resgroup/resgroup_set_memory_spill_ratio
test: resgroup/resgroup_unlimit_memory_spill_ratio
test: resgroup/resgroup_func_concurrency
test: resgroup/resgroup_cancel_terminate_concurrency
# memory spill tests
#test: resgroup/resgroup_memory_hashagg_spill
......
......@@ -17,46 +17,15 @@ CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
2&:BEGIN;
3:SET ROLE role_concurrency_test;
3&:BEGIN;
4:SET ROLE role_concurrency_test;
4&:BEGIN;
5:SET ROLE role_concurrency_test;
5&:BEGIN;
6:SET ROLE role_concurrency_test;
6&:BEGIN;
7:SET ROLE role_concurrency_test;
7&:BEGIN;
8:SET ROLE role_concurrency_test;
8&:BEGIN;
9:SET ROLE role_concurrency_test;
9&:BEGIN;
10:SET ROLE role_concurrency_test;
10&:BEGIN;
11:SET ROLE role_concurrency_test;
11&:BEGIN;
SELECT * FROM rg_concurrency_view;
SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE waiting_reason='resgroup' AND rsgname='rg_concurrency_test';
1:END;
2<:
3<:
4<:
5<:
6<:
7<:
8<:
9<:
10<:
11<:
SELECT * FROM rg_concurrency_view;
1q:
2q:
3q:
4q:
5q:
6q:
7q:
8q:
9q:
10q:
11q:
DROP ROLE role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -74,46 +43,15 @@ CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
2&:BEGIN;
3:SET ROLE role_concurrency_test;
3&:BEGIN;
4:SET ROLE role_concurrency_test;
4&:BEGIN;
5:SET ROLE role_concurrency_test;
5&:BEGIN;
6:SET ROLE role_concurrency_test;
6&:BEGIN;
7:SET ROLE role_concurrency_test;
7&:BEGIN;
8:SET ROLE role_concurrency_test;
8&:BEGIN;
9:SET ROLE role_concurrency_test;
9&:BEGIN;
10:SET ROLE role_concurrency_test;
10&:BEGIN;
11:SET ROLE role_concurrency_test;
11&:BEGIN;
SELECT * FROM rg_concurrency_view;
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE waiting_reason='resgroup' AND rsgname='rg_concurrency_test';
1:END;
2<:
3<:
4<:
5<:
6<:
7<:
8<:
9<:
10<:
11<:
SELECT * FROM rg_concurrency_view;
1q:
2q:
3q:
4q:
5q:
6q:
7q:
8q:
9q:
10q:
11q:
DROP ROLE role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -123,51 +61,27 @@ DROP ROLE IF EXISTS role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
-- end_ignore
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=5, cpu_rate_limit=20, memory_limit=20);
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=2, cpu_rate_limit=20, memory_limit=20);
CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
1:SET ROLE role_concurrency_test;
1&:SELECT pg_sleep(10000);
2:SET ROLE role_concurrency_test;
2&:SELECT pg_sleep(10000);
3:SET ROLE role_concurrency_test;
3&:SELECT pg_sleep(10000);
4:SET ROLE role_concurrency_test;
4&:SELECT pg_sleep(10000);
5:SET ROLE role_concurrency_test;
5&:SELECT pg_sleep(10000);
6:SET ROLE role_concurrency_test;
6&:BEGIN;
7:SET ROLE role_concurrency_test;
7&:BEGIN;
8:SET ROLE role_concurrency_test;
8&:BEGIN;
9:SET ROLE role_concurrency_test;
9&:BEGIN;
10:SET ROLE role_concurrency_test;
10&:BEGIN;
SELECT * FROM rg_concurrency_view;
SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE waiting='f' AND rsgname='rg_concurrency_test';
1<:
2<:
3<:
4<:
5<:
6<:
7<:
8<:
9<:
10<:
SELECT * FROM rg_concurrency_view;
1q:
2q:
3q:
4q:
5q:
6q:
7q:
8q:
9q:
10q:
DROP ROLE role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
......@@ -177,51 +91,27 @@ DROP ROLE IF EXISTS role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
-- end_ignore
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=5, cpu_rate_limit=20, memory_limit=20);
CREATE RESOURCE GROUP rg_concurrency_test WITH (concurrency=2, cpu_rate_limit=20, memory_limit=20);
CREATE ROLE role_concurrency_test RESOURCE GROUP rg_concurrency_test;
1:SET ROLE role_concurrency_test;
1&:SELECT pg_sleep(10000);
2:SET ROLE role_concurrency_test;
2&:SELECT pg_sleep(10000);
3:SET ROLE role_concurrency_test;
3&:SELECT pg_sleep(10000);
4:SET ROLE role_concurrency_test;
4&:SELECT pg_sleep(10000);
5:SET ROLE role_concurrency_test;
5&:SELECT pg_sleep(10000);
6:SET ROLE role_concurrency_test;
6&:BEGIN;
7:SET ROLE role_concurrency_test;
7&:BEGIN;
8:SET ROLE role_concurrency_test;
8&:BEGIN;
9:SET ROLE role_concurrency_test;
9&:BEGIN;
10:SET ROLE role_concurrency_test;
10&:BEGIN;
SELECT * FROM rg_concurrency_view;
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE waiting='f' AND rsgname='rg_concurrency_test';
1<:
2<:
3<:
4<:
5<:
6<:
7<:
8<:
9<:
10<:
SELECT * FROM rg_concurrency_view;
1q:
2q:
3q:
4q:
5q:
6q:
7q:
8q:
9q:
10q:
DROP ROLE role_concurrency_test;
DROP RESOURCE GROUP rg_concurrency_test;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册