| -- @Description Tests the state for pg_endpoints AND gp_get_segment_endpoints(), focus in wait mode |
| -- |
| DROP TABLE IF EXISTS t1; |
| DROP |
| CREATE TABLE t1 (a INT) DISTRIBUTED by (a); |
| CREATE |
| insert into t1 select generate_series(1,100); |
| INSERT 100 |
| |
| --------- Test1: Basic test for parallel retrieve interface & close cursor |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c1 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 1 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c1'; |
| endpoint_id1 | token_id | host_id | port_id | READY |
| endpoint_id1 | token_id | host_id | port_id | READY |
| endpoint_id1 | token_id | host_id | port_id | READY |
| (3 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c1', -1); <waiting ...> |
| |
| *U: @pre_run 'set_endpoint_variable @ENDPOINT1': SELECT state FROM gp_get_segment_endpoints() WHERE endpointname='@ENDPOINT1'; |
| state |
| ------- |
| (0 rows) |
| |
| state |
| ------- |
| READY |
| (1 row) |
| |
| state |
| ------- |
| READY |
| (1 row) |
| |
| state |
| ------- |
| READY |
| (1 row) |
| *R: @pre_run 'set_endpoint_variable @ENDPOINT1': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT1"; |
| #-1retrieve> connection to server at "host_id", port port_id failed: FATAL: retrieve auth token is invalid |
| |
| |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| 27 |
| 29 |
| 34 |
| 37 |
| 39 |
| 41 |
| 42 |
| 45 |
| 51 |
| 53 |
| 54 |
| 55 |
| 59 |
| 60 |
| 65 |
| 66 |
| 70 |
| 75 |
| 77 |
| 80 |
| 81 |
| 84 |
| 90 |
| 92 |
| 93 |
| 94 |
| 97 |
| 99 |
| (38 rows) |
| |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| |
| a |
| ----- |
| 5 |
| 6 |
| 9 |
| 10 |
| 11 |
| 13 |
| 14 |
| 17 |
| 21 |
| 25 |
| 28 |
| 32 |
| 33 |
| 43 |
| 52 |
| 56 |
| 58 |
| 62 |
| 63 |
| 67 |
| 73 |
| 82 |
| 85 |
| 96 |
| 100 |
| (25 rows) |
| |
| 1<: <... completed> |
| finished |
| ---------- |
| t |
| (1 row) |
| 1: CLOSE c1; |
| CLOSE |
| -- check no endpoint info |
| 1: SELECT auth_token,state FROM gp_get_endpoints() WHERE cursorname='c1'; |
| auth_token | state |
| ------------+------- |
| (0 rows) |
| -- check no token info on QE after close PARALLEL RETRIEVE CURSOR |
| *U: SELECT * FROM gp_get_segment_endpoints() WHERE cursorname='c1'; |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| -- error out for closed cursor |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c1', 0); |
| ERROR: cursor "c1" does not exist |
| 1: ROLLBACK; |
| ROLLBACK |
| |
| ---------- Test2: enhanced test for parallel retrieve interface state & cursor auto closed when transaction closed |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c2 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 2 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c2'; |
| endpoint_id2 | token_id | host_id | port_id | READY |
| endpoint_id2 | token_id | host_id | port_id | READY |
| endpoint_id2 | token_id | host_id | port_id | READY |
| (3 rows) |
| -- test RETRIEVE success on seg1 |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT2': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT2"; |
| a |
| ---- |
| 16 |
| 18 |
| 19 |
| 2 |
| 22 |
| 24 |
| 3 |
| 7 |
| 8 |
| 4 |
| (10 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c2', -1); <waiting ...> |
| |
| -- check initial state after "CHECK PARALLEL RETRIEVE CURSOR" |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c2'; |
| state |
| ---------- |
| ATTACHED |
| READY |
| READY |
| (3 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c2'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| t | t | ATTACHED |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| t | f | READY |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| t | f | READY |
| (1 row) |
| -- check state if some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT2': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT2"; |
| a |
| ---- |
| 27 |
| 29 |
| 34 |
| 37 |
| 39 |
| 41 |
| 42 |
| 45 |
| 51 |
| 53 |
| (10 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT2': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT2"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c2'; |
| state |
| ---------- |
| ATTACHED |
| FINISHED |
| READY |
| (3 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c2'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| t | t | ATTACHED |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| f | t | FINISHED |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| t | f | READY |
| (1 row) |
| -- return 0 row instead of reporting error if finished retrieving data from this endpoint, while other endpoint have not finished retrieving. |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT2': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT2"; |
| a |
| --- |
| (0 rows) |
| -- finished retrieving all endpoints and check state |
| *R: @pre_run 'set_endpoint_variable @ENDPOINT2': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT2"; |
| #-1retrieve> connection to server at "host_id", port port_id failed: FATAL: retrieve auth token is invalid |
| |
| |
| a |
| ---- |
| 54 |
| 55 |
| 59 |
| 60 |
| 65 |
| 66 |
| 70 |
| 75 |
| 77 |
| 80 |
| 81 |
| 84 |
| 90 |
| 92 |
| 93 |
| 94 |
| 97 |
| 99 |
| (18 rows) |
| |
| a |
| --- |
| (0 rows) |
| |
| a |
| ----- |
| 5 |
| 6 |
| 9 |
| 10 |
| 11 |
| 13 |
| 14 |
| 17 |
| 21 |
| 25 |
| 28 |
| 32 |
| 33 |
| 43 |
| 52 |
| 56 |
| 58 |
| 62 |
| 63 |
| 67 |
| 73 |
| 82 |
| 85 |
| 96 |
| 100 |
| (25 rows) |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c2'; |
| state |
| ---------- |
| FINISHED |
| FINISHED |
| FINISHED |
| (3 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c2'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| f | t | FINISHED |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| f | t | FINISHED |
| (1 row) |
| |
| ?column? | ?column? | state |
| ----------+----------+---------- |
| f | t | FINISHED |
| (1 row) |
| |
| 1<: <... completed> |
| finished |
| ---------- |
| t |
| (1 row) |
| 1: COMMIT; |
| COMMIT |
| -- check the cursor auto closed when transaction closed |
| -- check no endpoint info |
| 1: SELECT state FROM gp_get_endpoints() WHERE cursorname='c2'; |
| state |
| ------- |
| (0 rows) |
| -- check no token info on QE after close PARALLEL RETRIEVE CURSOR |
| *U: SELECT * FROM gp_get_segment_endpoints() WHERE cursorname='c2'; |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| -- error out for closed cursor |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c2', 0); |
| ERROR: cursor "c2" does not exist |
| 1: ROLLBACK; |
| ROLLBACK |
| |
| ---------- Test3: 2 retrieving sessions connect to the same endpoint report error & cancel QE exec backend |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c3 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 3 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c3'; |
| endpoint_id3 | token_id | host_id | port_id | READY |
| endpoint_id3 | token_id | host_id | port_id | READY |
| endpoint_id3 | token_id | host_id | port_id | READY |
| (3 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c3', -1); <waiting ...> |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT3': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT3"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| -- a new retrieve session should report error |
| 3R: @pre_run 'set_endpoint_variable @ENDPOINT3': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT3"; |
| ERROR: endpoint endpoint_id3 was already attached by receiver(pid: PID) |
| DETAIL: An endpoint can only be attached by one retrieving session. |
| -- quit this new retrieve session |
| 3Rq: ... <quitting> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT3': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT3"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| -- get senderpid which is endpoint execution backend |
| 0U: @post_run 'get_tuple_cell PID31 1 1 ; create_sub "$PID31[ \t]*" senderpid31': SELECT senderpid, receiverpid<>-1, state FROM gp_get_segment_endpoints(); |
| senderpid | ?column? | state |
| -----------+----------+---------- |
| senderpid31| t | ATTACHED |
| (1 row) |
| -- run 'kill -s INT senderpid' to cancel the endpoint execution backend, retrieve session still can work |
| 42: @pre_run 'kill -s INT ${PID31} && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: canceling MPP operation |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c3'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c3'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c3', -1); |
| ERROR: current transaction is aborted, commands ignored until end of transaction block |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c3'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c3'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ---------- Test4: terminate (using signal QUIT) QE exec backend |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c4 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 4 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c4'; |
| endpoint_id4 | token_id | host_id | port_id | READY |
| endpoint_id4 | token_id | host_id | port_id | READY |
| endpoint_id4 | token_id | host_id | port_id | READY |
| (3 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c4', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT4': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT4"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT4': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT4"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| -- get senderpid which is endpoint execution backend |
| 0U: @post_run 'get_tuple_cell PID41 1 1 ; create_sub "${PID41}[ \t]*" senderpid41': SELECT senderpid, receiverpid<>-1, state FROM gp_get_segment_endpoints(); |
| senderpid | ?column? | state |
| -----------+----------+---------- |
| senderpid41| t | ATTACHED |
| (1 row) |
| -- run 'kill -s QUIT senderpid' to cancel the endpoint execution backend, retrieve session still can work |
| 42: @pre_run 'kill -s QUIT ${PID41} && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- exit this session because the connection closed, so that it will re-connect next time use this session. |
| 0Rq: ... <quitting> |
| 0Uq: ... <quitting> |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: Error on receive from seg0 10.34.50.67:25432 pid=12603: server closed the connection unexpectedly |
| This probably means the server terminated abnormally |
| before or while processing the request. |
| -- check no endpoint info left |
| 2q: ... <quitting> |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c4'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c4'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c4', -1); |
| ERROR: current transaction is aborted, commands ignored until end of transaction block |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c4'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c4'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| 2Rq: ... <quitting> |
| |
| ---------- Test5: terminate (using signal TERM) QE exec backend |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c5 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 5 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c5'; |
| endpoint_id5 | token_id | host_id | port_id | READY |
| endpoint_id5 | token_id | host_id | port_id | READY |
| endpoint_id5 | token_id | host_id | port_id | READY |
| (3 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c5', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT5': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT5"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| -- 1R still bind to Test4 session, so can not retrieve from current endpoint. |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT5': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT5"; |
| ERROR: the endpoint endpoint_id5 does not exist for session id xxx |
| -- Since seg1 retrieve session is bind to Test4 session. And Test4 session get killed. We need to restart it. |
| 1Rq: ... <quitting> |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT5': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT5"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| -- get senderpid which is endpoint execution backend |
| 0U: @post_run 'get_tuple_cell PID51 1 1 ; create_sub "${PID51}[ \t]*" senderpid51': SELECT senderpid, receiverpid<>-1, state FROM gp_get_segment_endpoints(); |
| senderpid | ?column? | state |
| -----------+----------+---------- |
| senderpid51| t | ATTACHED |
| (1 row) |
| -- run 'kill -s TERM senderpid' to cancel the endpoint execution backend, retrieve session still can work |
| 42: @pre_run 'kill -s TERM ${PID51} && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: terminating connection due to administrator command (seg0 10.34.50.67:25432 pid=12905) |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c5'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c5'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c5', -1); |
| ERROR: current transaction is aborted, commands ignored until end of transaction block |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c5'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c5'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ---------- Test6: Cancel (using signal INT) the process of 'CHECK PARALLEL RETRIEVE CURSOR' |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c6 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 6 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c6'; |
| endpoint_id6 | token_id | host_id | port_id | READY |
| endpoint_id6 | token_id | host_id | port_id | READY |
| endpoint_id6 | token_id | host_id | port_id | READY |
| (3 rows) |
| -- get backend pid of this session which run 'gp_wait_parallel_retrieve_cursor' |
| 1: @post_run 'get_tuple_cell PID61 1 1 ; create_sub "${PID61}[ \t]*" QDPid61': select pg_backend_pid(); |
| pg_backend_pid |
| ---------------- |
| QDPid61 |
| (1 row) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c6', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT6': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT6"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT6': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT6"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| -- run 'kill -s INT QDPid' to cancel the endpoint execution backend, retrieve session still can work |
| 42: @pre_run 'kill -s INT ${PID61} && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: canceling statement due to user request |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c6'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c6'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c6', -1); |
| ERROR: current transaction is aborted, commands ignored until end of transaction block |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c6'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c6'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ---------- Test6.1: Cancel (using signal INT) the process of 'CHECK PARALLEL RETRIEVE CURSOR' without rollback |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c61 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 61 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c61'; |
| endpoint_id61 | token_id | host_id | port_id | READY |
| endpoint_id61 | token_id | host_id | port_id | READY |
| endpoint_id61 | token_id | host_id | port_id | READY |
| (3 rows) |
| -- get backend pid of this session which run 'gp_wait_parallel_retrieve_cursor' |
| 1: @post_run 'get_tuple_cell PID611 1 1 ; create_sub "${PID611}[ \t]*" QDPid611': select pg_backend_pid(); |
| pg_backend_pid |
| ---------------- |
| QDPid611 |
| (1 row) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c61', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT61': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT61"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT61': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT61"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| -- run 'kill -s INT QDPid' to cancel the endpoint execution backend, retrieve session still can work |
| 42: @pre_run 'kill -s INT ${PID611} && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: canceling statement due to user request |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c61'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c61'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- quit the session of 'CHECK PARALLEL RETRIEVE CURSOR' and keep other session connected |
| 1q: ... <quitting> |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c61'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c61'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| 0Rq: ... <quitting> |
| 1Rq: ... <quitting> |
| |
| ---------- Test7: terminate (using signal QUIT) the process of 'CHECK PARALLEL RETRIEVE CURSOR' |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c7 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 7 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c7'; |
| endpoint_id7 | token_id | host_id | port_id | READY |
| endpoint_id7 | token_id | host_id | port_id | READY |
| endpoint_id7 | token_id | host_id | port_id | READY |
| (3 rows) |
| -- get backend pid of this session which run 'gp_wait_parallel_retrieve_cursor' |
| 1: @post_run 'get_tuple_cell PID71 1 1 ; create_sub "${PID71}[ \t]*" QDPid71': select pg_backend_pid(); |
| pg_backend_pid |
| ---------------- |
| QDPid71 |
| (1 row) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c7', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT7': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT7"; |
| a |
| ---- |
| 2 |
| 3 |
| 4 |
| 7 |
| 8 |
| 16 |
| 18 |
| 19 |
| 22 |
| 24 |
| (10 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT7': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT7"; |
| a |
| ---- |
| 1 |
| 12 |
| 15 |
| 20 |
| 23 |
| 26 |
| 30 |
| 31 |
| 35 |
| 36 |
| 38 |
| 40 |
| 44 |
| 46 |
| 47 |
| 48 |
| 49 |
| 50 |
| 57 |
| 61 |
| 64 |
| 68 |
| 69 |
| 71 |
| 72 |
| 74 |
| 76 |
| 78 |
| 79 |
| 83 |
| 86 |
| 87 |
| 88 |
| 89 |
| 91 |
| 95 |
| 98 |
| (37 rows) |
| 2U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c7'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| t | f | READY |
| (1 row) |
| -- run 'kill -s QUIT QDPid' to cancel the endpoint execution backend, retrieve session still can work |
| -- here need to sleep sometime to wait for endpoint QE backend to detect QD connection lost. |
| 0U: @pre_run 'kill -s QUIT ${PID71}&& sleep 5 && echo "${RAW_STR}" ': SELECT 1; |
| ?column? |
| ---------- |
| 1 |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| server closed the connection unexpectedly |
| This probably means the server terminated abnormally |
| before or while processing the request. |
| -- quit all sessions on the master, because connect lost |
| 1q: ... <quitting> |
| 2q: ... <quitting> |
| -1Uq: ... <quitting> |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c7'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c7'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c7', -1); |
| ERROR: cursor "c7" does not exist |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c7'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c7'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ---------- Test8: Status visibilities for different sessions |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c8 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'get_tuple_cell SESSION81 1 1 ; create_match_sub_with_spaces $SESSION81 session81': SELECT sessionid,state FROM gp_get_session_endpoints() WHERE cursorname='c8'; |
| sessionid | state |
| -----------+------- |
| session81 | READY |
| session81 | READY |
| session81 | READY |
| (3 rows) |
| -- Session 2 can only see its own cursors by default. |
| 2: BEGIN; |
| BEGIN |
| 2: DECLARE c8 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 2: @post_run 'get_tuple_cell SESSION82 1 1 ; create_match_sub_with_spaces $SESSION82 session82': SELECT sessionid,state FROM gp_get_session_endpoints() WHERE cursorname='c8'; |
| sessionid | state |
| -----------+------- |
| session82 | READY |
| session82 | READY |
| session82 | READY |
| (3 rows) |
| -- Session 2 can see all cursors with gp_get_endpoints(). |
| 2: SELECT sessionid,state FROM gp_get_endpoints() WHERE cursorname='c8' order by sessionid; |
| sessionid | state |
| -----------+------- |
| session82 | READY |
| session82 | READY |
| session82 | READY |
| session81 | READY |
| session81 | READY |
| session81 | READY |
| (6 rows) |
| |
| 1: CLOSE c8; |
| CLOSE |
| 1: END; |
| END |
| 2: CLOSE c8; |
| CLOSE |
| 2: END; |
| END |
| |
| ---------- Test9: Cancel (using pg_cancel_backend(pid)) the process of 'CHECK PARALLEL RETRIEVE CURSOR' |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c9 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 9 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c9'; |
| endpoint_id9 | token_id | host_id | port_id | READY |
| endpoint_id9 | token_id | host_id | port_id | READY |
| endpoint_id9 | token_id | host_id | port_id | READY |
| (3 rows) |
| |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c9', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT9': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT9"; |
| ERROR: the endpoint endpoint_id9 does not exist for session id xxx |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT9': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT9"; |
| ERROR: the endpoint endpoint_id9 does not exist for session id xxx |
| -- run pg_cancel_backend(pid) to cancel the endpoint execution backend, retrieve session still can work |
| 2: select pg_cancel_backend(pid) from pg_stat_activity where query like 'SELECT * FROM gp_wait_parallel_retrieve_cursor(''c9'', -1);'; |
| pg_cancel_backend |
| ------------------- |
| t |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... completed> |
| ERROR: canceling statement due to user request |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c9'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c9'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c9', -1); |
| ERROR: current transaction is aborted, commands ignored until end of transaction block |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c9'; |
| state |
| ------- |
| (0 rows) |
| |
| ---------- Test10: terminate (using pg_terminate_backend(pid)) the process of 'CHECK PARALLEL RETRIEVE CURSOR' |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c10 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t1; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 10 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c10'; |
| endpoint_id10 | token_id | host_id | port_id | READY |
| endpoint_id10 | token_id | host_id | port_id | READY |
| endpoint_id10 | token_id | host_id | port_id | READY |
| (3 rows) |
| 1&: SELECT * FROM gp_wait_parallel_retrieve_cursor('c10', -1); <waiting ...> |
| -- some endpoint retrieve partial results, some endpoint finished retrieving, some endpoint not start retrieving |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT10': RETRIEVE 10 FROM ENDPOINT "@ENDPOINT10"; |
| ERROR: the endpoint endpoint_id10 does not exist for session id xxx |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT10': RETRIEVE ALL FROM ENDPOINT "@ENDPOINT10"; |
| ERROR: the endpoint endpoint_id10 does not exist for session id xxx |
| 2U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c10'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| t | f | READY |
| (1 row) |
| -- run ' pg_terminate_backend(pid)' to cancel the endpoint execution backend, retrieve session still can work |
| -- here need to sleep sometime to wait for endpoint QE backend to detect QD connection lost. |
| 2: select pg_terminate_backend(pid) from pg_stat_activity where query like 'SELECT * FROM gp_wait_parallel_retrieve_cursor(''c10'', -1);'; |
| pg_terminate_backend |
| ---------------------- |
| t |
| (1 row) |
| -- check it can cancel the "gp_wait_parallel_retrieve_cursor" |
| 1<: <... 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. |
| -- quit all sessions on the master, because connect lost |
| 1q: ... <quitting> |
| 2q: ... <quitting> |
| -1Uq: ... <quitting> |
| -- check no endpoint info left |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c10'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c10'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| -- report error for EXECUTE canceled PARALLEL RETRIEVE CURSOR |
| 1: SELECT * FROM gp_wait_parallel_retrieve_cursor('c10', -1); |
| ERROR: cursor "c10" does not exist |
| 1: ROLLBACK; |
| ROLLBACK |
| -- check no endpoint info |
| 2: SELECT state FROM gp_get_endpoints() WHERE cursorname='c10'; |
| state |
| ------- |
| (0 rows) |
| *U: SELECT senderpid<>-1, receiverpid<>-1, state FROM gp_get_segment_endpoints() WHERE cursorname='c10'; |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| |
| ?column? | ?column? | state |
| ----------+----------+------- |
| (0 rows) |
| 0Rq: ... <quitting> |
| 1Rq: ... <quitting> |
| |
| --------- Test11: Test t1 has large amount of tuples, only retreive small number of tuples, we can still close cursor. |
| 1:DROP TABLE IF EXISTS t2; |
| DROP |
| 1:CREATE TABLE t2 (id integer, data text) DISTRIBUTED by (id); |
| CREATE |
| 1:INSERT INTO t2 select id, 'test ' || id from generate_series(1,100000) id; |
| INSERT 100000 |
| |
| 1: BEGIN; |
| BEGIN |
| 1: DECLARE c11 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM t2; |
| DECLARE |
| 1: @post_run 'parse_endpoint_info 11 1 2 3 4' : SELECT endpointname,auth_token,hostname,port,state FROM gp_get_endpoints() WHERE cursorname='c11'; |
| endpoint_id11 | token_id | host_id | port_id | READY |
| endpoint_id11 | token_id | host_id | port_id | READY |
| endpoint_id11 | token_id | host_id | port_id | READY |
| (3 rows) |
| 0R: @pre_run 'set_endpoint_variable @ENDPOINT11': RETRIEVE 5 FROM ENDPOINT "@ENDPOINT11"; |
| id | data |
| ----+-------- |
| 2 | test 2 |
| 3 | test 3 |
| 4 | test 4 |
| 7 | test 7 |
| 8 | test 8 |
| (5 rows) |
| 1R: @pre_run 'set_endpoint_variable @ENDPOINT11': RETRIEVE 5 FROM ENDPOINT "@ENDPOINT11"; |
| id | data |
| ----+--------- |
| 1 | test 1 |
| 12 | test 12 |
| 15 | test 15 |
| 20 | test 20 |
| 23 | test 23 |
| (5 rows) |
| 2R: @pre_run 'set_endpoint_variable @ENDPOINT11': RETRIEVE 5 FROM ENDPOINT "@ENDPOINT11"; |
| id | data |
| ----+--------- |
| 5 | test 5 |
| 6 | test 6 |
| 9 | test 9 |
| 10 | test 10 |
| 11 | test 11 |
| (5 rows) |
| |
| 1: CLOSE c11; |
| CLOSE |
| 1: ROLLBACK; |
| ROLLBACK |
| |
| -- check no endpoint info |
| 1: SELECT auth_token,state FROM gp_get_endpoints() WHERE cursorname='c11'; |
| auth_token | state |
| ------------+------- |
| (0 rows) |
| -- check no token info on QE after close PARALLEL RETRIEVE CURSOR |
| *U: SELECT * FROM gp_get_segment_endpoints() WHERE cursorname='c11'; |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |
| |
| auth_token | databaseid | senderpid | receiverpid | state | gp_segment_id | sessionid | username | endpointname | cursorname |
| ------------+------------+-----------+-------------+-------+---------------+-----------+----------+--------------+------------ |
| (0 rows) |