Updated on 2024-04-03 GMT+08:00

Technical Architecture

Context

Database sessions may be interrupted during a primary/standby switchover, minor version upgrade, or instance class change. Applications need to check session statuses and react to changes by determining:

  • If the database connection has been interrupted.
  • If the transaction has been interrupted.
  • How to perform transaction compensation.
  • How to rebuild the database session context.

Application Lossless and Transparent (ALT) ensures application continuity with no data loss during a primary/standby switchover or failover. When ALT is enabled:

  • Connection and transaction interruptions can be avoided.
  • There is no need for transaction compensation.
  • There is no need to recover or rebuild session context.

Precautions

  • Enabling or disabling ALT will cause your RDS instance and proxy instance to reboot.
  • ALT is not supported when the multi-proxy function is enabled.
  • The transaction drain 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 and time-consuming transactions.
    • Decreasing this interval is not recommended. If there are connections that do not drain transactions within the configured transaction drain timeout interval, ALT does not take effect for these connections.

ALT Architecture

ALT can be enabled for your application connections. Figure 1 shows the ALT architecture.

Figure 1 ALT architecture

When ALT is enabled for your applications:

  1. The applications need to be connected to the database proxy.
  2. During a primary/standby switchover, instance class change, or minor version upgrade, RDS replicates database sessions.
  3. The transaction logs are drained to establish secure transaction boundaries.

    A secure transaction boundary is when a transaction in the current session has been committed but the next transaction has not yet 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.
    • An XA transaction is committed or rolled back.
  4. Database sessions are switched by transferring session contexts.

    Session clone can copy and transfer session statuses, including session system variables, user-defined variables, and other contexts like DB_NAME.