Updated on 2024-11-06 GMT+08:00

Introducing ALT

Database sessions may be interrupted when a read replica is promoted to primary, a minor version is upgraded, or specifications are changed. Applications need to check session statuses and react to changes by determining: whether a database connection or transaction has been interrupted, how to compensate for transactions, and how to rebuild session contexts.

To address these issues, GaussDB(for MySQL) provides ALT, which prevents database connection and transaction interruptions during database system switchover. There is no need to compensate for transactions or rebuild session contexts, ensuring application continuity.

Architecture

Figure 1 Architecture

ALT can be enabled for your application connections. When you connect to a proxy instance and then promote a read replica to primary, change specifications, or upgrade the minor version, the system can replicate your backend sessions. Once a secure transaction boundary is reached, backend sessions will be fully cloned to the destination node, and workloads do not even notice.

A secure transaction boundary refers to the status that a transaction in the current session has been committed but the next transaction is not started. A secure transaction boundary can be reached in any of the following situations:

  • Each statement in a transaction block with autocommit enabled is executed.
    start transaction;
    DML;
    commit;
  • The commit operation is complete with autocommit disabled.
  • A single DML or DDL statement is executed.
  • The lock is released when a table lock, backup lock, or user-defined lock is used.

Precautions

Table 1 Precautions

Category

Precaution

Version constraints

  • The kernel version of the GaussDB(for MySQL) instance must be 2.0.54.240600 or later.
  • The kernel version of the proxy instance must be 2.24.06.000 or later.

Usage constraints

  • To use ALT, submit an application by choosing Service Tickets > Create Service Ticket in the upper right corner of the management console.
  • The GaussDB(for MySQL) instance has at least one read replica. A proxy instance has been created and the GaussDB(for MySQL) instance must be connected through the proxy address.
  • Proxy instances in read-only mode do not support ALT.
  • Proxy instances in primary/standby mode do not support ALT.
  • Single-node or multi-primary GaussDB(for MySQL) instances do not support ALT.
  • When you enable ALT for the first time, the GaussDB(for MySQL) instance will reboot. Enabling or disabling ALT will cause a proxy instance to reboot. Once ALT is disabled for all proxy instances, the GaussDB (for MySQL) instance will also reboot.
  • The transaction draining timeout interval for ALT is controlled by rds_tac_drain_timeout. This parameter defaults to 5s and ranges from 1s to 60s.
    • Increase this interval for heavy workloads, numerous prepared statements, or time-consuming transactions.
    • Decreasing this interval is not recommended. If there are connections that do not drain transactions within the configured transaction draining timeout interval, ALT does not take effect for these connections.
  • During an ALT switchover, standby connections will be established on the new host for a brief period, equal in number to those on the original primary node. Ensure that the maximum number of connections of the GaussDB(for MySQL) instance is at least twice the current number of connections. To change the maximum number of connections, you need to evaluate the instance specifications and memory usage. For details, see What Is the Maximum Number of Connections to a GaussDB(for MySQL) Instance?
  • ALT supports prepared statements. During a switchover, the contexts of prepared statements are rebuilt. If there are a large number of prepared statements, the switchover success rate may be affected.
  • You are advised to perform an ALT switchover during off-peak hours. If the primary node and read replicas are overloaded, the switchover success rate may be affected.
  • For details about syntax and function constraints of proxy instances, see Precautions for Proxy Instances.

Unsupported functions

  • Enabling ALT makes your instance lose support for some system variable values.
    • innodb_ft_user_stopword_table: It can only be set to NULL.
    • transaction_write_set_extraction: It can only be set to OFF.
    • profiling: It cannot be set to 1 or ON.
  • ALT does not support Transparent Data Encryption (TDE).
  • ALT is unavailable when any of the following proxy capabilities is enabled:
    • Session-level connection pool
    • Any column containing more than 16 MB of data
    • Prepared statement cache
  • ALT does not support temporary tables created by users.
  • ALT is not supported in the following scenarios where a secure transaction boundary cannot be reached:
    • InnoDB transaction blocks are not committed in a timely manner.
    • There are unreleased table locks, user locks, backup locks, and binlog locks.
    • XA transactions are not committed or rolled back.
  • ALT will be likely to fail if a switchover, minor version upgrade, or specification change occurs frequently within a short period of time.
  • If ALT is enabled, prepared statements cannot be transferred in the following scenarios:
    • The cursor is opened and not closed in a prepared statement.
    • The variable of a prepared statement has saved the LONG_DATA type.