blob: 89462405b1d787383329263843174fcf7efbbb20 [file] [log] [blame]
--
-- Test what happens, when an ERROR occurs at various stages of COMMIT
-- or ABORT processing. This test uses the fault injection mechanism
-- built in to the server, to induce an ERROR at strategic places.
--
-- Create a plain table that we can insert to, to verify after the
-- transaction whether the transaction's effects are visible.
CREATE TABLE dtm_testtab(id int4);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry 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.
-- throw an ERROR, just after we have broadcast the PREPARE of the
-- transaction to segments.
select gp_inject_fault('dtm_broadcast_prepare', 'error', 1::smallint);
gp_inject_fault
-----------------
t
(1 row)
insert into dtm_testtab values (1), (2);
ERROR: fault triggered, fault name:'dtm_broadcast_prepare' fault type:'error' (faultinjector.c:671)
select * from dtm_testtab;
id
----
(0 rows)
-- throw an ERROR, in master, just before we have broadcast the COMMIT
-- PREPARED to segments.
select gp_inject_fault('dtm_broadcast_commit_prepared', 'error', 1::smallint);
gp_inject_fault
-----------------
t
(1 row)
insert into dtm_testtab values (3), (4);
ERROR: fault triggered, fault name:'dtm_broadcast_commit_prepared' fault type:'error' (faultinjector.c:671)
select * from dtm_testtab;
-- FIXME: You currently get an:
-- "We should not be trying to execute a query in state 'Segment Prepared'"
-- error at this point. That's not good.