mirror of https://github.com/citusdata/citus.git
Fix prepared statement bug when switching from local to remote execution
parent
a9f8a60007
commit
e683993449
|
@ -556,9 +556,8 @@ ExtractLocalAndRemoteTasks(bool readOnly, List *taskList, List **localTaskList,
|
||||||
* At this point, we're dealing with a task that has placements on both
|
* At this point, we're dealing with a task that has placements on both
|
||||||
* local and remote nodes.
|
* local and remote nodes.
|
||||||
*/
|
*/
|
||||||
task->partiallyLocalOrRemote = true;
|
|
||||||
|
|
||||||
Task *localTask = copyObject(task);
|
Task *localTask = copyObject(task);
|
||||||
|
localTask->partiallyLocalOrRemote = true;
|
||||||
|
|
||||||
localTask->taskPlacementList = localTaskPlacementList;
|
localTask->taskPlacementList = localTaskPlacementList;
|
||||||
*localTaskList = lappend(*localTaskList, localTask);
|
*localTaskList = lappend(*localTaskList, localTask);
|
||||||
|
@ -572,6 +571,7 @@ ExtractLocalAndRemoteTasks(bool readOnly, List *taskList, List **localTaskList,
|
||||||
/* since shard replication factor > 1, we should have at least 1 remote task */
|
/* since shard replication factor > 1, we should have at least 1 remote task */
|
||||||
Assert(remoteTaskPlacementList != NIL);
|
Assert(remoteTaskPlacementList != NIL);
|
||||||
Task *remoteTask = copyObject(task);
|
Task *remoteTask = copyObject(task);
|
||||||
|
remoteTask->partiallyLocalOrRemote = true;
|
||||||
remoteTask->taskPlacementList = remoteTaskPlacementList;
|
remoteTask->taskPlacementList = remoteTaskPlacementList;
|
||||||
|
|
||||||
*remoteTaskList = lappend(*remoteTaskList, remoteTask);
|
*remoteTaskList = lappend(*remoteTaskList, remoteTask);
|
||||||
|
|
|
@ -1522,6 +1522,51 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.distri
|
||||||
EXECUTE local_multi_row_insert_prepare_params(5,11);
|
EXECUTE local_multi_row_insert_prepare_params(5,11);
|
||||||
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
|
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
-- make sure that we still get results if we switch off local execution
|
||||||
|
PREPARE ref_count_prepare AS SELECT count(*) FROM reference_table;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.reference_table_1470000 reference_table
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.reference_table_1470000 reference_table
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.reference_table_1470000 reference_table
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.reference_table_1470000 reference_table
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.reference_table_1470000 reference_table
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.enable_local_execution TO off;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
7
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
RESET citus.enable_local_execution;
|
||||||
-- failures of local execution should rollback both the
|
-- failures of local execution should rollback both the
|
||||||
-- local execution and remote executions
|
-- local execution and remote executions
|
||||||
-- fail on a local execution
|
-- fail on a local execution
|
||||||
|
|
|
@ -691,7 +691,16 @@ BEGIN;
|
||||||
EXECUTE local_multi_row_insert_prepare_params(5,11);
|
EXECUTE local_multi_row_insert_prepare_params(5,11);
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- make sure that we still get results if we switch off local execution
|
||||||
|
PREPARE ref_count_prepare AS SELECT count(*) FROM reference_table;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
SET citus.enable_local_execution TO off;
|
||||||
|
EXECUTE ref_count_prepare;
|
||||||
|
RESET citus.enable_local_execution;
|
||||||
|
|
||||||
-- failures of local execution should rollback both the
|
-- failures of local execution should rollback both the
|
||||||
-- local execution and remote executions
|
-- local execution and remote executions
|
||||||
|
|
Loading…
Reference in New Issue