mirror of https://github.com/citusdata/citus.git
Start remote transactions in master_append_table_to_shard
Add a call to RemoteTransactionBeginIfNecessary so that BEGIN is actually sent to the remote connections. This means that ROLLBACK and Ctrl-C are respected and don't leave the table in a partial state.pull/1198/head
parent
1ff9d68e68
commit
e3c763c3f7
|
@ -278,6 +278,8 @@ master_append_table_to_shard(PG_FUNCTION_ARGS)
|
|||
quote_literal_cstr(sourceTableName),
|
||||
quote_literal_cstr(sourceNodeName), sourceNodePort);
|
||||
|
||||
RemoteTransactionBeginIfNecessary(connection);
|
||||
|
||||
executeResult = ExecuteOptionalRemoteCommand(connection, workerAppendQuery->data,
|
||||
&queryResult);
|
||||
PQclear(queryResult);
|
||||
|
|
|
@ -138,5 +138,16 @@ WHERE 'multi_append_table_to_shard_date'::regclass::oid = logicalrelid;
|
|||
|
||||
SELECT * FROM multi_append_table_to_shard_date;
|
||||
|
||||
-- When run inside aborted transaction does not persist changes
|
||||
INSERT INTO multi_append_table_to_shard_stage VALUES ('2016-02-02', 4);
|
||||
BEGIN;
|
||||
SELECT master_append_table_to_shard(shardid, 'multi_append_table_to_shard_stage', 'localhost', 57636)
|
||||
FROM
|
||||
pg_dist_shard
|
||||
WHERE 'multi_append_table_to_shard_date'::regclass::oid = logicalrelid;
|
||||
ROLLBACK;
|
||||
|
||||
SELECT * FROM multi_append_table_to_shard_date;
|
||||
|
||||
DROP TABLE multi_append_table_to_shard_stage;
|
||||
DROP TABLE multi_append_table_to_shard_date;
|
||||
|
|
|
@ -227,5 +227,26 @@ SELECT * FROM multi_append_table_to_shard_date;
|
|||
01-01-2016 | 3
|
||||
(3 rows)
|
||||
|
||||
-- When run inside aborted transaction does not persist changes
|
||||
INSERT INTO multi_append_table_to_shard_stage VALUES ('2016-02-02', 4);
|
||||
BEGIN;
|
||||
SELECT master_append_table_to_shard(shardid, 'multi_append_table_to_shard_stage', 'localhost', 57636)
|
||||
FROM
|
||||
pg_dist_shard
|
||||
WHERE 'multi_append_table_to_shard_date'::regclass::oid = logicalrelid;
|
||||
master_append_table_to_shard
|
||||
------------------------------
|
||||
0.0266667
|
||||
(1 row)
|
||||
|
||||
ROLLBACK;
|
||||
SELECT * FROM multi_append_table_to_shard_date;
|
||||
event_date | value
|
||||
------------+-------
|
||||
|
|
||||
|
|
||||
01-01-2016 | 3
|
||||
(3 rows)
|
||||
|
||||
DROP TABLE multi_append_table_to_shard_stage;
|
||||
DROP TABLE multi_append_table_to_shard_date;
|
||||
|
|
Loading…
Reference in New Issue