citus/src/backend/distributed/operations
Jelte Fennema abffa6c3b9
Use shard split copy code for blocking shard moves (#6098)
The new shard copy code that was created for shard splits has some
advantages over the old shard copy code. The old code was using 
worker_append_table_to_shard, which wrote to disk twice. And it also 
didn't use binary copy when that was possible. Both of these issues
were fixed in the new copy code. This PR starts using this new copy
logic also for shard moves, not just for shard splits.

On my local machine I created a single shard table like this.
```sql
set citus.shard_count = 1;
create table t(id bigint, a bigint);
select create_distributed_table('t', 'id');

INSERT into t(id, a) SELECT i, i from generate_series(1, 100000000) i;
```

I then turned `fsync` off to make sure I wasn't bottlenecked by disk. 
Finally I moved this shard between nodes with `citus_move_shard_placement`
with `block_writes`.

Before this PR a move took ~127s, after this PR it took only ~38s. So for this 
small test this resulted in spending ~70% less time.

And I also tried the same test for a table that contained large strings:
```sql
set citus.shard_count = 1;
create table t(id bigint, a bigint, content text);
select create_distributed_table('t', 'id');

INSERT into t(id, a, content) SELECT i, i, 'aunethautnehoautnheaotnuhetnohueoutnehotnuhetncouhaeohuaeochgrhgd.athbetndairgexdbuhaobulrhdbaetoausnetohuracehousncaoehuesousnaceohuenacouhancoexdaseohusnaetobuetnoduhasneouhaceohusnaoetcuhmsnaetohuacoeuhebtokteaoshetouhsanetouhaoug.lcuahesonuthaseauhcoerhuaoecuh.lg;rcydabsnetabuesabhenth' from generate_series(1, 20000000) i;
```
2022-08-01 20:10:36 +03:00
..
citus_create_restore_point.c Move CheckCitusVersion to the top of each function 2021-06-01 17:43:46 +02:00
citus_split_shard_by_split_points.c Shard Split for Citus (#6029) 2022-07-18 02:54:15 -07:00
citus_tools.c Allow distributed execution from run_command_on_* functions 2022-05-20 15:26:47 +02:00
create_shards.c refactor code where GetObjectAddressFromParseTree is called because it returns list of addresses now 2022-07-19 18:13:12 +03:00
delete_protocol.c Prevent cache usage on citus_drop_trigger codepaths 2021-11-18 20:24:51 +03:00
health_check.c Make pg_version_compat.h and listutils.c dependency-free. (#5548) 2022-01-04 23:02:08 -08:00
isolate_shards.c Shard Split for Citus (#6029) 2022-07-18 02:54:15 -07:00
modify_multiple_shards.c Clean up multi_shard_commit_protocol guc leftovers (#6110) 2022-08-01 15:22:02 +03:00
node_protocol.c Remove useless version compats 2022-07-29 10:31:55 +02:00
partitioning.c Move CheckCitusVersion to the top of each function 2021-06-01 17:43:46 +02:00
repair_shards.c Use shard split copy code for blocking shard moves (#6098) 2022-08-01 20:10:36 +03:00
shard_cleaner.c Make enterprise features open source (#6008) 2022-06-16 00:23:46 -07:00
shard_rebalancer.c Concurrent shard move/copy and colocated table creation fix 2022-07-27 10:01:19 +02:00
shard_split.c Add colocation checks for shard splits 2022-07-27 10:01:19 +02:00
stage_protocol.c refactor code where GetObjectAddressFromParseTree is called because it returns list of addresses now 2022-07-19 18:13:12 +03:00
worker_copy_table_to_node_udf.c Use shard split copy code for blocking shard moves (#6098) 2022-08-01 20:10:36 +03:00
worker_node_manager.c Make sure citus_is_coordinator works on read replicas 2022-07-13 14:11:18 +02:00
worker_shard_copy.c Shard Split for Citus (#6029) 2022-07-18 02:54:15 -07:00
worker_split_copy_udf.c Shard Split for Citus (#6029) 2022-07-18 02:54:15 -07:00