提交 ea2ad511 编写于 作者: K Kenan Yao

Stablize regression tests of dispatcher.

Signed-off-by: NPengzhou Tang <ptang@pivotal.io>
上级 db398280
......@@ -25,7 +25,7 @@ test: leastsquares
test: opr_sanity_gp decode_expr bitmapscan bitmapscan_ao case_gp limit_gp notin percentile naivebayes join_gp union_gp gpcopy gp_create_table
test: filter gpctas gpdist matrix toast sublink table_functions olap_setup complex opclass_ddl information_schema guc_env_var
test: bitmap_index gp_dump_query_oids
test: indexjoin as_alias regex_gp gpparams with_clause transient_types gang_mgmt
test: indexjoin as_alias regex_gp gpparams with_clause transient_types
# dispatch should always run seperately from other cases.
test: dispatch
......
......@@ -83,14 +83,14 @@ CREATE OR REPLACE FUNCTION cleanupAllGangs() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'cleanupAllGangs' LANGUAGE C;
-- check if segments has backend running
CREATE OR REPLACE FUNCTION numBackendsOnSegment() RETURNS INTEGER
CREATE OR REPLACE FUNCTION numBackendsOnSegment(int) RETURNS INTEGER
AS '@abs_builddir@/regress@DLSUFFIX@', 'numBackendsOnSegment' LANGUAGE C;
-- check if QD has reusable gangs
CREATE OR REPLACE FUNCTION hasGangsExist() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'hasGangsExist' LANGUAGE C;
CREATE VIEW v_hasBackendsOnSegment as select sum(numBackendsOnSegment()) > 0 from
CREATE VIEW v_hasBackendsOnSegment as select sum(numBackendsOnSegment(30)) > 0 from
gp_dist_random('gp_id');
-- disable debug linger to get immediate feedback from FATAL errors.
......@@ -156,12 +156,6 @@ select 'wait recovery finish' from gp_dist_random('gp_id');
-- cleanup all reusable gangs
select cleanupAllGangs();
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
-- expect no zombie backends left on segments
select * from v_hasBackendsOnSegment;
......@@ -185,12 +179,6 @@ where dispatch_test_t1.c2 = dispatch_test_t2.c2 and dispatch_test_t2.c3 = dispat
-- expect no resuable gang exist
select * from hasGangsExist();
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
-- expect no zombie backends left on segments.
select * from v_hasBackendsOnSegment;
......@@ -208,12 +196,6 @@ where dispatch_test_t1.c2 = dispatch_test_t2.c2 and dispatch_test_t2.c3 = dispat
-- expect resuable gang exist
select * from hasGangsExist();
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
-- expect QEs exist.
select * from v_hasBackendsOnSegment;
......@@ -260,3 +242,22 @@ select * from dispatch_test_t1, dispatch_test_t2, dispatch_test_t3
where dispatch_test_t1.c2 = dispatch_test_t2.c2 and dispatch_test_t2.c3 = dispatch_test_t3.c3;
\! gpfaultinjector -q -f after_one_slice_dispatched -y reset --seg_dbid 1
-- test logging of gang management
SET gp_log_gang = 'debug';
-- test INFO raised from segments with various kinds of fields
CREATE OR REPLACE FUNCTION udf_raise_info() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'gangRaiseInfo' LANGUAGE C;
SELECT udf_raise_info() FROM gp_dist_random('gp_id') WHERE gp_segment_id = 0;
-- terminate connections to all segments
\c
-- test brutal exit of session can correctly clean up all QEs
-- start and finish a new session
\! psql regression -f @abs_builddir@/sql/dispatch_test_helper.sql
-- verify all QEs of the exited session have gone, expect to return false
select * from v_hasBackendsOnSegment;
-- test logging of gang management
SET gp_log_gang = 'debug';
-- test INFO raised from segments with various kinds of fields
CREATE OR REPLACE FUNCTION udf_raise_info() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'gangRaiseInfo' LANGUAGE C;
SELECT udf_raise_info() FROM gp_dist_random('gp_id') WHERE gp_segment_id = 0;
-- terminate connections to all segments
\c
-- test brutal exit of session can correctly clean up all QEs
-- start and finish a new session
\! psql regression -f @abs_builddir@/sql/gang_mgmt_helper.sql
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
-- verify all QEs of the exited session have gone, expect to return nothing
SELECT sess_id FROM tmp_sess_id, (SELECT get_segment_qe_session_ids() FROM gp_dist_random('gp_id')) sessions WHERE tmp_sess_id.sess_id = sessions.get_segment_qe_session_ids;
......@@ -105,12 +105,12 @@ insert into dispatch_test_t3 values (3,1,2);
CREATE OR REPLACE FUNCTION cleanupAllGangs() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'cleanupAllGangs' LANGUAGE C;
-- check if segments has backend running
CREATE OR REPLACE FUNCTION numBackendsOnSegment() RETURNS INTEGER
CREATE OR REPLACE FUNCTION numBackendsOnSegment(int) RETURNS INTEGER
AS '@abs_builddir@/regress@DLSUFFIX@', 'numBackendsOnSegment' LANGUAGE C;
-- check if QD has reusable gangs
CREATE OR REPLACE FUNCTION hasGangsExist() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'hasGangsExist' LANGUAGE C;
CREATE VIEW v_hasBackendsOnSegment as select sum(numBackendsOnSegment()) > 0 from
CREATE VIEW v_hasBackendsOnSegment as select sum(numBackendsOnSegment(30)) > 0 from
gp_dist_random('gp_id');
-- disable debug linger to get immediate feedback from FATAL errors.
set gp_debug_linger to 0;
......@@ -200,16 +200,6 @@ select cleanupAllGangs();
t
(1 row)
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- expect no zombie backends left on segments
select * from v_hasBackendsOnSegment;
?column?
......@@ -250,16 +240,6 @@ select * from hasGangsExist();
f
(1 row)
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- expect no zombie backends left on segments.
select * from v_hasBackendsOnSegment;
?column?
......@@ -290,16 +270,6 @@ select * from hasGangsExist();
t
(1 row)
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- expect QEs exist.
select * from v_hasBackendsOnSegment;
?column?
......@@ -356,3 +326,38 @@ select * from dispatch_test_t1, dispatch_test_t2, dispatch_test_t3
where dispatch_test_t1.c2 = dispatch_test_t2.c2 and dispatch_test_t2.c3 = dispatch_test_t3.c3;
ERROR: canceling statement due to user request
\! gpfaultinjector -q -f after_one_slice_dispatched -y reset --seg_dbid 1
-- test logging of gang management
SET gp_log_gang = 'debug';
-- test INFO raised from segments with various kinds of fields
CREATE OR REPLACE FUNCTION udf_raise_info() RETURNS BOOL
AS '@abs_builddir@/regress@DLSUFFIX@', 'gangRaiseInfo' LANGUAGE C;
SELECT udf_raise_info() FROM gp_dist_random('gp_id') WHERE gp_segment_id = 0;
INFO: testing hook function MPPnoticeReceiver (seg0 slice1 172.17.0.2:25432 pid=34013)
DETAIL: this test aims at covering code paths not hit before
HINT: no special hint
CONTEXT: PL/C function defined in regress.c
udf_raise_info
----------------
t
(1 row)
-- terminate connections to all segments
\c
-- test brutal exit of session can correctly clean up all QEs
-- start and finish a new session
\! psql regression -f @abs_builddir@/sql/dispatch_test_helper.sql
BEGIN
DECLARE CURSOR
SET
psql:@abs_builddir@/sql/dispatch_test_helper.sql:10: FATAL: User fault injection raised fatal
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:@abs_builddir@/sql/dispatch_test_helper.sql:10: connection to server was lost
-- verify all QEs of the exited session have gone, expect to return false
select * from v_hasBackendsOnSegment;
?column?
----------
f
(1 row)
-- test logging of gang management
SET gp_log_gang = 'debug';
-- test INFO raised from segments with various kinds of fields
CREATE OR REPLACE FUNCTION udf_raise_info() RETURNS BOOL
AS '@abs_srcdir@/regress.so', 'gangRaiseInfo' LANGUAGE C;
SELECT udf_raise_info() FROM gp_dist_random('gp_id') WHERE gp_segment_id = 0;
INFO: testing hook function MPPnoticeReceiver (seg0 slice1 127.0.0.1:10000 pid=9647)
DETAIL: this test aims at covering code paths not hit before
HINT: no special hint
CONTEXT: PL/C function defined in regress.c
udf_raise_info
----------------
t
(1 row)
-- terminate connections to all segments
\c
-- test brutal exit of session can correctly clean up all QEs
-- start and finish a new session
\! psql regression -f @abs_srcdir@/sql/gang_mgmt_helper.sql
psql:@abs_srcdir@/sql/gang_mgmt_helper.sql:5: NOTICE: table "tmp_sess_id" does not exist, skipping
DROP TABLE
psql:@abs_srcdir@/sql/gang_mgmt_helper.sql:6: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'sess_id' 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.
SELECT 1
CREATE FUNCTION
BEGIN
DECLARE CURSOR
SET
psql:@abs_srcdir@/sql/gang_mgmt_helper.sql:18: FATAL: User fault injection raised fatal
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:@abs_srcdir@/sql/gang_mgmt_helper.sql:18: connection to server was lost
-- sleep 1 second to wait all QEs to exit, since QE exit in this situation is an
-- asynchronous procedure, 1 second may not guarantee they have exited in
-- extreme poor performant machines, but we have no better solution now, and this
-- test case is pretty necessary, so...
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- verify all QEs of the exited session have gone, expect to return nothing
SELECT sess_id FROM tmp_sess_id, (SELECT get_segment_qe_session_ids() FROM gp_dist_random('gp_id')) sessions WHERE tmp_sess_id.sess_id = sessions.get_segment_qe_session_ids;
sess_id
---------
(0 rows)
......@@ -2473,15 +2473,26 @@ PG_FUNCTION_INFO_V1(numBackendsOnSegment);
Datum
numBackendsOnSegment(PG_FUNCTION_ARGS)
{
int beid;
int32 result = 0;
int beid;
int32 result;
int timeout = PG_GETARG_INT32(0);
if (timeout <= 0)
elog(ERROR, "timeout expected to be larger than 0");
int pid = getpid();
int tot_backends = pgstat_fetch_stat_numbackends();
for (beid = 1; beid <= tot_backends; beid++)
while (timeout > 0)
{
PgBackendStatus *beentry = pgstat_fetch_stat_beentry(beid);
if (beentry && beentry->st_procpid >0 && beentry->st_procpid != pid)
result++;
result = 0;
int tot_backends = pgstat_fetch_stat_numbackends();
for (beid = 1; beid <= tot_backends; beid++)
{
PgBackendStatus *beentry = pgstat_fetch_stat_beentry(beid);
if (beentry && beentry->st_procpid >0 && beentry->st_procpid != pid)
result++;
}
if (result == 0)
break;
sleep(1); /* 1 second */
timeout--;
}
PG_RETURN_INT32(result);
......
......@@ -27,6 +27,5 @@ external_table.sql
largeobject.sql
qp_gist_indexes2.sql
qp_regexp.sql
gang_mgmt.sql
guc_env_var.sql
dispatch.sql
-- this is a SQL file invoked by gang_mgmt.sql, and should not be executed
-- this is a SQL file invoked by dispatch.sql, and should not be executed
-- directly in any test schedule;
-- preserve current session id into a table
DROP TABLE IF EXISTS tmp_sess_id;
SELECT sess_id INTO tmp_sess_id FROM pg_stat_activity WHERE procpid = pg_backend_pid();
-- UDF that returns the set of backend session ids in one segment(duplications
-- included), will be invoked by gang_mgmt.sql to do verification
CREATE OR REPLACE FUNCTION get_segment_qe_session_ids() RETURNS SETOF int AS $$ SELECT pg_stat_get_backend_session_id(pg_stat_get_backend_idset) FROM pg_stat_get_backend_idset(); $$ LANGUAGE SQL;
BEGIN;
DECLARE c1 CURSOR FOR SELECT pg_sleep(300) FROM gp_dist_random('gp_id');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册