You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: develop/api_udf.rst
+94-3Lines changed: 94 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -444,7 +444,7 @@ Arguments
444
444
**node_port:** The port on which PostgreSQL is listening on the worker node.
445
445
446
446
**group_id:** A group of one primary server and zero or more secondary
447
-
servers, relevant only for streaming replication. Default 0
447
+
servers, relevant only for streaming replication. Default -1
448
448
449
449
**node_role:** Whether it is 'primary' or 'secondary'. Default 'primary'
450
450
@@ -494,6 +494,36 @@ Example
494
494
495
495
select * from master_update_node(123, 'new-address', 5432);
496
496
497
+
.. _master_set_node_property:
498
+
499
+
master_set_node_property
500
+
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
501
+
502
+
The master_set_node_property() function changes properties in the Citus metadata table :ref:`pg_dist_node <pg_dist_node>`. Currently it can change only the ``shouldhaveshards`` property.
503
+
504
+
Arguments
505
+
************************
506
+
507
+
**node_name:** DNS name or IP address for the node.
508
+
509
+
**node_port:** the port on which PostgreSQL is listening on the worker node.
510
+
511
+
**property:** the column to change in ``pg_dist_node``, currently only ``shouldhaveshard`` is supported.
512
+
513
+
**value:** the new value for the column.
514
+
515
+
Return Value
516
+
******************************
517
+
518
+
N/A
519
+
520
+
Example
521
+
***********************
522
+
523
+
.. code-block:: postgresql
524
+
525
+
SELECT * FROM master_set_node_property('localhost', 5433, 'shouldhaveshards', false);
526
+
497
527
.. _master_add_inactive_node:
498
528
499
529
master_add_inactive_node
@@ -512,7 +542,7 @@ Arguments
512
542
**node_port:** The port on which PostgreSQL is listening on the worker node.
513
543
514
544
**group_id:** A group of one primary server and zero or more secondary
515
-
servers, relevant only for streaming replication. Default 0
545
+
servers, relevant only for streaming replication. Default -1
516
546
517
547
**node_role:** Whether it is 'primary' or 'secondary'. Default 'primary'
518
548
@@ -1006,7 +1036,7 @@ The rebalance_table_shards() function moves shards of the given table to make th
1006
1036
Arguments
1007
1037
**************************
1008
1038
1009
-
**table_name:** The name of the table whose shards need to be rebalanced.
1039
+
**table_name:** (Optional) The name of the table whose shards need to be rebalanced. If NULL, then rebalance all existing colocation groups.
1010
1040
1011
1041
**threshold:** (Optional) A float number between 0.0 and 1.0 which indicates the maximum difference ratio of node utilization from average utilization. For example, specifying 0.1 will cause the shard rebalancer to attempt to balance all nodes to hold the same number of shards ±10%. Specifically, the shard rebalancer will try to converge utilization of all worker nodes to the (1 - threshold) * average_utilization ... (1 + threshold) * average_utilization range.
1012
1042
@@ -1020,6 +1050,8 @@ Arguments
1020
1050
* ``force_logical``: Use logical replication even if the table doesn't have a replica identity. Any concurrent update/delete statements to the table will fail during replication.
1021
1051
* ``block_writes``: Use COPY (blocking writes) for tables lacking primary key or replica identity.
1022
1052
1053
+
**drain_only:** (Optional) When true, move shards off worker nodes who have ``shouldhaveshards`` set to false in :ref:`pg_dist_node`; move no other shards.
The master_drain_node function is a part of Citus Enterprise. Please `contact us <https://www.citusdata.com/about/contact_us>`_ to obtain this functionality.
1131
+
1132
+
The master_drain_node() function moves shards off the designated node and onto other nodes who have ``shouldhaveshards`` set to true in :ref:`pg_dist_node`. This function is designed to be called prior to removing a node from the cluster, i.e. turning the node's physical server off.
1133
+
1134
+
Arguments
1135
+
**************************
1136
+
1137
+
**nodename:** The hostname name of the node to be drained.
1138
+
1139
+
**nodeport:** The port number of the node to be drained.
1140
+
1141
+
**shard_transfer_mode:** (Optional) Specify the method of replication, whether to use PostgreSQL logical replication or a cross-worker COPY command. The possible values are:
1142
+
1143
+
* ``auto``: Require replica identity if logical replication is possible, otherwise use legacy behaviour (e.g. for shard repair, PostgreSQL 9.6). This is the default value.
1144
+
* ``force_logical``: Use logical replication even if the table doesn't have a replica identity. Any concurrent update/delete statements to the table will fail during replication.
1145
+
* ``block_writes``: Use COPY (blocking writes) for tables lacking primary key or replica identity.
1146
+
1147
+
Return Value
1148
+
*********************************
1149
+
1150
+
N/A
1151
+
1152
+
Example
1153
+
**************************
1154
+
1155
+
Here are the typical steps to remove a single node (for example '10.0.0.1' on a standard PostgreSQL port):
1156
+
1157
+
1. Drain the node.
1158
+
1159
+
.. code-block:: postgresql
1160
+
1161
+
SELECT * from master_drain_node('10.0.0.1', 5432);
1162
+
1163
+
2. Wait until the command finishes
1164
+
3. Remove the node
1165
+
1166
+
When draining multiple nodes it's recommended to use :ref:`rebalance_table_shards` instead. Doing so allows Citus to plan ahead and move shards the minimum number of times.
1167
+
1168
+
1. Run this for each node that you want to remove:
1169
+
1170
+
.. code-block:: postgresql
1171
+
1172
+
SELECT * FROM master_set_node_property(node_hostname, node_port, 'shouldhaveshards', false);
1173
+
1174
+
2. Drain them all at once with :ref:`rebalance_table_shards`:
1175
+
1176
+
.. code-block:: postgresql
1177
+
1178
+
SELECT * FROM rebalance_table_shards(drain_only := true);
0 commit comments