Outdated Version

You are viewing an older version of this section. View current production version.

Engine Variables

MemSQL defines engine variables as either sync or non-sync. The following sections discuss these variables and how to set them.

Sync Variables

Sync variables are cluster-wide variables that you set on the master aggregator. After you set a sync variable, your update is propagated to all aggregators, all leaves, or both. The nodes affected by your update depend on the variable’s type and the command you use to set the variable. Your update takes effect immediately on the affected nodes (unless the variable’s scope is “Session that can also be set globally”) and persists if the affected nodes are restarted.

Types of Sync Variables

There are three types of sync variables:

  • Variables that can sync to all aggregators.
  • Variables that can sync to all leaves.
  • Variables that can sync to all nodes (leaves and aggregators).

The last sentence of the “Description” column in the list of sync variables specifies each variable’s type.

Sync Variable Scopes

Every variable has one of the following scopes.

  • Global. When you set a global variable, its value is effective for your current connection to the node and any other existing or subsequent connections, initiated by any user.
  • Session that can also be set globally. When set for the session, the variable’s value is effective for your current connection to the node. When set globally, this variable’s value is NOT effective for your current connection to the node but is effective for any other existing or subsequent connections to the node, initiated by any user.

Most sync variables have global scope. Those that instead have the scope “session that can also be set globally” are indicated in the “Description” column in the list of sync variables.

Note: Use the @@ selector to read the value of a variable. See Reading Variables for more information.

Setting Sync Variables

You can set a sync variable in the following ways:

  • Using a SingleStore client, run one of the following three commands: run SET CLUSTER to sync a variable to all nodes or to all aggregators; run SET AGGREGATOR to sync a variable to all aggregators; run SET LEAF to sync a variable to all leaves.
  • At the Linux command line, run the following command to update the node’s configuration, according to whether you are using the SingleStore DB Tools or MemSQL Ops to manage your cluster.

SingleStore DB Tools:

Run MEMSQL-ADMIN UPDATE-CONFIG.

MemSQL Ops:

Run MEMSQL-OPS MEMSQL-UPDATE-CONFIG.

Include the --set-global flag. Using the -memsql-id parameter, specify the master aggregator node.

See the list of sync variables that you can set.

Alert

You can set a sync variable on the master aggregator only. You will receive an error if you attempt to set a sync variable on any other type of node.

You should not set a sync variable by editing the memsql.cnf file. Attempting to do so may result in an error, or the setting may have no effect. Instead, set sync variables using methods described above.

Non-Sync Variables

Non-sync variables are set to take effect on individual nodes. They have one the following four states:

  • Settable to take effect when a node starts
  • Settable to take effect while a node is running
  • Settable to take effect both when a node starts and while the node is running
  • Read-only (not settable)

Most non-sync variables are settable to take effect both when a node starts and while the node is running. Exceptions are indicated in the “Exceptions to When Variable can be Set” column in the list of non-sync variables.

Non-Sync Variable Scopes

Every non-sync variable has one of the following scopes.

  • Global. When you set a global variable, its value is effective for your current connection to the node and any other existing or subsequent connections, initiated by any user.
  • Session that can also be set globally. When set for the session, the variable’s value is effective for your current connection to the node. When set globally, this variable’s value is NOT effective for your current connection to the node but is effective for any other existing or subsequent connections to the node, initiated by any user.

Most non-sync variables have global scope. Those that instead have the scope “session that can also be set globally” are indicated in the “Description” column in the list of non-sync variables.

Note: Use the @@ selector to read the value of a variable. See Reading Variables for more information.

Setting Non-Sync Variables

SET SESSION sets a session variable. SET GLOBAL sets a variable globally. If you use either of these commands to set a non-sync variable, the variable’s value will not persist if the node is restarted.

To set the variable’s value to take effect when the node starts, run the following command to update the node’s configuration, according to whether you are using the SingleStore DB Tools or MemSQL Ops to manage your cluster.

SingleStore DB Tools:

Run MEMSQL-ADMIN UPDATE-CONFIG at the Linux command line.

MemSQL Ops:

Run MEMSQL-OPS MEMSQL-UPDATE-CONFIG at the Linux command line.

Specify the --all flag if you want to propagate the non-sync variable’s value to all nodes. You can also use the --set-global flag to have the variable’s value take effect immediately (assuming the node is running and the variable can be set at runtime) in addition to when the node restarts.

See the list of non-sync variables that you can set.

Alert

When you add new nodes to a cluster, non-sync variables that you set previously are not automatically applied to the new nodes.

Reading Variables

To retrieve the value of a variable, use the @@ selector with the variable in a SELECT statement. For example,

SELECT @@sql_mode;
****
+-------------------+
| @@sql_mode        |
+-------------------+
| STRICT_ALL_TABLES |
+-------------------+
1 row in set (0.27 sec)