xsql_ha_set_switch_mode

Change the HA switch mode.

For an overview see page HA Applications

Prototype

     
    bool xsql_ha_set_switch_mode( switch_mode );
     

Arguments

switch_mode The switch_mode to change to

Description

This function takes a single string parameter - "auto", "master", "replica" or "standalone" and returns false if the previous value of switch_mode was the same (i.e. the mode was not actually changed) or true otherwise. In case of errors it throws an exception (as most other UDFs).

In the "auto" mode, if the xSQL configuration file specifies master and replica side parameters, the HA runtime runs xSQL in a replica mode and makes several attempts to connect to the master node. If those attempts are unsuccessful, then xSQL is runs as a master.

In the "master" mode xSQL will only be run s a master, regardless of the replica parameters in its configuration file; in the "replica" mode xSQL only runs as a replica, again regardless of the master parameters in the config file. In the "standalone" mode the xSQL server temporarily ignores HA all together.

Example

 
    XSQL>select xsql_ha_set_switch_mode('auto);
    #1
    ------------------------------------------------------------------------------
    true
     
    Selected records: 1
     
    XSQL>select xsql_ha_set_switch_mode('bad mode');
    #1
    ------------------------------------------------------------------------------
    ERROR: Possible parameter values are 'auto', 'master', 'replica' or 'standalone'