Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f6d6e71

Browse files
committed
Dirty init scripts updates, resetting node id on node deletion
1 parent 3828649 commit f6d6e71

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

bin/common.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@ function restart_nodes()
4949
done
5050
pg_ctl -o "-p $master_port" -D $master_datadir restart
5151
}
52+
53+
function run_demo()
54+
{
55+
psql -p 5433 -c "drop table if exists partitioned_table cascade;"
56+
psql -p 5433 -c "CREATE TABLE partitioned_table(id INT NOT NULL, payload REAL);"
57+
psql -p 5433 -c "INSERT INTO partitioned_table SELECT generate_series(1, 1000), random();"
58+
psql -c "select shardman.add_node('port=5433');"
59+
psql -c "select shardman.add_node('port=5434');"
60+
sleep 5
61+
psql -c "select shardman.create_hash_partitions(2, 'partitioned_table', 'id', 2);"
62+
}

bin/shardman_init.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ done
3535

3636
restart_nodes
3737

38-
psql -p 5433 -c "drop table if exists partitioned_table cascade;"
39-
psql -p 5433 -c "CREATE TABLE partitioned_table(id INT NOT NULL, payload REAL);"
40-
psql -p 5433 -c "INSERT INTO partitioned_table SELECT generate_series(1, 1000), random();"
41-
psql -c "select shardman.add_node('port=5433');"
42-
psql -c "select shardman.add_node('port=5434');"
43-
44-
psql -c "select shardman.create_hash_partitions(2, 'partitioned_table', 'id', 2);"
38+
run_demo
4539

4640
psql

bin/shardman_start.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ source "${script_dir}/common.sh"
55

66
cd "${script_dir}/.."
77
make clean
8-
make install
98

109
restart_nodes
1110
for port in $master_port "${worker_ports[@]}"; do
1211
psql -p $port -c "drop extension if exists pg_shardman;"
12+
done
13+
14+
restart_nodes
15+
make install
16+
for port in $master_port "${worker_ports[@]}"; do
1317
psql -p $port -c "create extension pg_shardman cascade;"
1418
done
19+
1520
# to restart master bgw
1621
restart_nodes
1722

18-
psql -p 5433 -c "drop table if exists partitioned_table cascade;"
19-
psql -p 5433 -c "CREATE TABLE partitioned_table(id INT NOT NULL, payload REAL);"
20-
psql -p 5433 -c "INSERT INTO partitioned_table SELECT generate_series(1, 1000), random();"
21-
psql -c "select shardman.add_node('port=5433');"
22-
psql -c "select shardman.add_node('port=5434');"
23+
run_demo
2324

2425
psql

pg_shardman--0.0.1.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ BEGIN
155155
IF um_opts != '' THEN
156156
um_opts := format(' OPTIONS (%s)', um_opts);
157157
END IF;
158-
raise log 'serv opts are %, um opts are %', server_opts, um_opts;
159158
EXECUTE format('CREATE SERVER %I FOREIGN DATA WRAPPER
160159
postgres_fdw %s;', NEW.part_name, server_opts);
161160
EXECUTE format('DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER %I;',
@@ -363,6 +362,8 @@ BEGIN
363362
WHERE slot_name LIKE 'shardman_%' AND slot_type = 'logical' LOOP
364363
EXECUTE format('SELECT pg_drop_replication_slot(%L)', rs.slot_name);
365364
END LOOP;
365+
366+
PERFORM shardman.reset_node_id();
366367
END;
367368
$$ LANGUAGE plpgsql;
368369
CREATE FUNCTION pg_shardman_cleanup_c() RETURNS event_trigger

0 commit comments

Comments
 (0)