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

Commit 772d974

Browse files
committed
rm_node fixed.
* Cleanup now called only on removed node. * Node is not deleted from the nodes table to avoid problems with foreign keys.
1 parent 49a2e9d commit 772d974

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

membership.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88

99
-- active is the normal mode, others needed only for proper node add and removal
10-
CREATE TYPE worker_node_status AS ENUM ('active', 'add_in_progress', 'rm_in_progress');
10+
CREATE TYPE worker_node_status AS ENUM (
11+
'active', 'add_in_progress', 'rm_in_progress', 'removed');
1112

1213
-- list of nodes present in the cluster
1314
CREATE TABLE nodes (
@@ -30,7 +31,10 @@ CREATE TABLE nodes (
3031
-- of transaction. Later we should delete subscriptions fully.
3132
CREATE FUNCTION rm_node_worker_side() RETURNS TRIGGER AS $$
3233
BEGIN
33-
PERFORM shardman.pg_shardman_cleanup(false);
34+
IF OLD.id = (SELECT shardman.get_node_id()) THEN
35+
RAISE DEBUG '[SHARDMAN] rm_node_worker_side called';
36+
PERFORM shardman.pg_shardman_cleanup(false);
37+
END IF;
3438
RETURN NULL;
3539
END
3640
$$ LANGUAGE plpgsql;

src/pg_shardman.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,9 @@ rm_node(Cmd *cmd)
690690
*/
691691
sql = psprintf(
692692
"select shardman.drop_repslot('shardman_meta_sub_%d');"
693-
/* keep silent cmd_log fk constraint */
694-
"update shardman.cmd_log set node_id = null where node_id = %d;"
695-
"delete from shardman.nodes where id = %d;"
693+
"update shardman.nodes set worker_status = 'removed' where id = %d;"
696694
"update shardman.cmd_log set status = 'success' where id = %ld;",
697-
node_id, node_id, node_id, cmd->id);
695+
node_id, node_id, cmd->id);
698696
void_spi(sql);
699697
pfree(sql);
700698
elog(INFO, "Node %d successfully removed", node_id);

0 commit comments

Comments
 (0)