pg_terminate_backend.out 1.9 KB
Newer Older
1 2 3 4 5 6 7
create table foo as select i a, i b from generate_series(1, 10) i;
CREATE 10

-- expect this query terminated by 'test pg_terminate_backend'
1&:create temp table t as select count(*) from foo where pg_sleep(20) is null;  <waiting ...>

-- extract the pid for the previous query
R
Richard Guo 已提交
8
SELECT pg_terminate_backend(pid,'test pg_terminate_backend') FROM pg_stat_activity WHERE query like 'create temp table t as select%' ORDER BY pid LIMIT 1;
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
pg_terminate_backend
--------------------
t                   
(1 row)

-- EXPECT: session 1 terminated with 'test pg_terminate_backend'
1<:  <... completed>
FATAL:  terminating connection due to administrator command: "test pg_terminate_backend"
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

-- query backend to ensure no PANIC on postmaster
select count(*) from foo;
count
-----
10   
(1 row)
N
Ning Yu 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

--
-- SIGSEGV issue when freeing gangs
--

CREATE EXTENSION IF NOT EXISTS gp_inject_fault;
CREATE

DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (c1 int, c2 int) DISTRIBUTED BY (c1);
CREATE

10: BEGIN;
BEGIN

SELECT gp_inject_fault('create_gang_in_progress', 'reset', 1);
gp_inject_fault
---------------
t              
(1 row)
SELECT gp_inject_fault('create_gang_in_progress', 'suspend', 1);
gp_inject_fault
---------------
t              
(1 row)

10&: SELECT * FROM foo a JOIN foo b USING (c2);  <waiting ...>

SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE query = 'SELECT * FROM foo a JOIN foo b USING (c2);';
pg_terminate_backend
--------------------
t                   
(1 row)

SELECT gp_inject_fault('create_gang_in_progress', 'resume', 1);
gp_inject_fault
---------------
t              
(1 row)

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.
10q