mirror of https://github.com/citusdata/citus.git
Merge pull request #2367 from citusdata/fix_wrong_escaping
Do not recover wrong distributed transactions in MXpull/2360/head
commit
5ddba6a7cd
|
@ -420,7 +420,7 @@ PendingWorkerTransactionList(MultiConnection *connection)
|
||||||
int coordinatorId = GetLocalGroupId();
|
int coordinatorId = GetLocalGroupId();
|
||||||
|
|
||||||
appendStringInfo(command, "SELECT gid FROM pg_prepared_xacts "
|
appendStringInfo(command, "SELECT gid FROM pg_prepared_xacts "
|
||||||
"WHERE gid LIKE 'citus_%d_%%'",
|
"WHERE gid LIKE 'citus\\_%d\\_%%'",
|
||||||
coordinatorId);
|
coordinatorId);
|
||||||
|
|
||||||
querySent = SendRemoteCommand(connection, command->data);
|
querySent = SendRemoteCommand(connection, command->data);
|
||||||
|
|
|
@ -50,15 +50,29 @@ PREPARE TRANSACTION 'citus_12_should_commit';
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE should_be_sorted_into_middle (value int);
|
CREATE TABLE should_be_sorted_into_middle (value int);
|
||||||
PREPARE TRANSACTION 'citus_12_should_be_sorted_into_middle';
|
PREPARE TRANSACTION 'citus_12_should_be_sorted_into_middle';
|
||||||
|
-- this node (e.g., node id 12) should not touch
|
||||||
|
-- transactions with different nodeIds in the gid
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE table_should_do_nothing (value int);
|
||||||
|
PREPARE TRANSACTION 'citus_122_should_do_nothing';
|
||||||
-- Add "fake" pg_dist_transaction records and run recovery
|
-- Add "fake" pg_dist_transaction records and run recovery
|
||||||
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_commit');
|
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_commit');
|
||||||
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_be_forgotten');
|
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_be_forgotten');
|
||||||
|
INSERT INTO pg_dist_transaction VALUES (122, 'citus_122_should_do_nothing');
|
||||||
SELECT recover_prepared_transactions();
|
SELECT recover_prepared_transactions();
|
||||||
recover_prepared_transactions
|
recover_prepared_transactions
|
||||||
-------------------------------
|
-------------------------------
|
||||||
3
|
3
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- delete the citus_122_should_do_nothing transaction
|
||||||
|
DELETE FROM pg_dist_transaction WHERE gid = 'citus_122_should_do_nothing' RETURNING *;
|
||||||
|
groupid | gid
|
||||||
|
---------+-----------------------------
|
||||||
|
122 | citus_122_should_do_nothing
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ROLLBACK PREPARED 'citus_122_should_do_nothing';
|
||||||
SELECT count(*) FROM pg_dist_transaction;
|
SELECT count(*) FROM pg_dist_transaction;
|
||||||
count
|
count
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -36,11 +36,23 @@ BEGIN;
|
||||||
CREATE TABLE should_be_sorted_into_middle (value int);
|
CREATE TABLE should_be_sorted_into_middle (value int);
|
||||||
PREPARE TRANSACTION 'citus_12_should_be_sorted_into_middle';
|
PREPARE TRANSACTION 'citus_12_should_be_sorted_into_middle';
|
||||||
|
|
||||||
|
-- this node (e.g., node id 12) should not touch
|
||||||
|
-- transactions with different nodeIds in the gid
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE table_should_do_nothing (value int);
|
||||||
|
PREPARE TRANSACTION 'citus_122_should_do_nothing';
|
||||||
|
|
||||||
-- Add "fake" pg_dist_transaction records and run recovery
|
-- Add "fake" pg_dist_transaction records and run recovery
|
||||||
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_commit');
|
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_commit');
|
||||||
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_be_forgotten');
|
INSERT INTO pg_dist_transaction VALUES (12, 'citus_12_should_be_forgotten');
|
||||||
|
INSERT INTO pg_dist_transaction VALUES (122, 'citus_122_should_do_nothing');
|
||||||
|
|
||||||
SELECT recover_prepared_transactions();
|
SELECT recover_prepared_transactions();
|
||||||
|
|
||||||
|
-- delete the citus_122_should_do_nothing transaction
|
||||||
|
DELETE FROM pg_dist_transaction WHERE gid = 'citus_122_should_do_nothing' RETURNING *;
|
||||||
|
ROLLBACK PREPARED 'citus_122_should_do_nothing';
|
||||||
|
|
||||||
SELECT count(*) FROM pg_dist_transaction;
|
SELECT count(*) FROM pg_dist_transaction;
|
||||||
|
|
||||||
SELECT count(*) FROM pg_tables WHERE tablename = 'table_should_abort';
|
SELECT count(*) FROM pg_tables WHERE tablename = 'table_should_abort';
|
||||||
|
|
Loading…
Reference in New Issue