SET GLOBAL. This command allows administrators to update long-lived connections (such as those from connection pools) when runtime parameters are adjusted, without requiring connections to reconnect.
Background
By default,SET GLOBAL in the database only affects newly created connections. Existing sessions keep their local copies of session variables until they disconnect or explicitly run SET SESSION. This behavior is consistent with MySQL but makes it difficult to update long-lived connections when administrators adjust runtime parameters.
The REFRESH CONNECTIONS command solves this problem by allowing administrators to refresh all active connections to apply the latest global variable values.
Tip
This command requires the OPERATE privilege on the SYSTEM object.
Syntax
Parameters
Behavior
-
Selective refresh: By default, the command only refreshes variables that have not been modified by the session itself. Variables that were explicitly set using
SET SESSIONare preserved. WhenFORCEis specified, all variables are refreshed regardless of session modifications. - Immediate execution: Running statements are not affected immediately. The refresh takes effect before the next command is executed.
- Distribution: The command is automatically distributed to all FE nodes via RPC, ensuring consistency across the cluster.
- Privilege requirement: Only users with OPERATE privilege on the SYSTEM object can execute this command.
Examples
Example 1: Refresh all connections after changing a global variable.REFRESH CONNECTIONS, all active connections (except those that have modified query_timeout in their session) will have their query_timeout value updated to 600.
Example 2: Refresh connections after changing multiple global variables.
REFRESH CONNECTIONS FORCE, all active connections will have their query_timeout value updated to 600, even if they previously modified this variable using SET SESSION query_timeout = 500.
Notes
-
By default, variables that have been modified in a session using
SET SESSIONare not refreshed. For example, if a connection has executedSET SESSION query_timeout = 500, thequery_timeoutvalue for that connection will remain 500 even afterREFRESH CONNECTIONSis executed. However, if you useREFRESH CONNECTIONS FORCE, all variables will be refreshed regardless of session modifications. -
When
FORCEis specified, variables that were previously modified by the session are reset to the global default values, and their modification flags are cleared. This allows future non-forced refreshes to update these variables. - The command affects all active connections on all FE nodes in the cluster.
- Session-only variables (variables that cannot be set globally) are not affected by this command.
-
Variables with the
DISABLE_FORWARD_TO_LEADERflag are not refreshed.
Related Statements
- SET: Set system variables or user-defined variables
- SHOW VARIABLES: Show system variables