Troubleshooting an unreachable member cluster or a stall
When routed work in a database cluster group for Aurora fails or stalls, first find out whether one member cluster or the routing layer is the cause. Check each member cluster directly and through the routing endpoint. Choose a fix only after a cause matches, because a restart can end routed sessions without fixing the cause. For how the routing layer runs across Availability Zones and what happens when part of it fails, see Routing layer and routing endpoint.
The checks are read-only. Each member cluster still serves your application, so open each direct session on it as read-only, with statement and lock time limits. For the settings, see Before you start: what to collect.
A member cluster is unreachable through the routing endpoint
Symptom. Routed statements to one member cluster fail, but direct connections to it work and the other member clusters route normally. On Aurora MySQL, routed statements return error 1429 (Member cluster is currently unavailable: no healthy endpoint) when the routing layer has no available instance of the member cluster to send them to, or error 1105 (Member cluster unavailable; reconnect and retry the statement) when it chose an instance and couldn't open a session on it, or error 1053 (SQLSTATE 08S01) when the member cluster doesn't accept the session or doesn't open it in time. For the codes, see Routing and data mapping errors. If routed statements fail for one user only, see A statement is refused instead.
Check. Run the following checks in order. The statements for each step follow, except the step for the AWS CLI.
To find why a member cluster is unreachable
-
At the routing endpoint, run one routed read for each data mapping on several new connections. On each member cluster (direct), run a trivial read. A
SELECT 1at the routing endpoint proves only the sign-in, because the routing layer answers it itself. Read a mapped table instead. -
At the routing endpoint, check that
member_cluster_mappingslists the member cluster, as shown in Before you start: what to collect. Then pin a session to it. A listed member cluster that doesn't answer a pin isn't routable. On Aurora MySQL, a pin to a member cluster that the routing layer can't reach returns error1429(HY000) withThe member cluster is unreachable, and the pin doesn't take effect. Fix the cause in the following table before you pin again. -
On Aurora MySQL, on the member cluster (direct), count its sessions by connection source. If it has no sessions that the routing layer opened while routed statements to it fail, the failure is on the path from the routing layer to that member cluster.
-
At the routing endpoint, read
dbclustergroup_sys.data_mappings. Compare each mapping's collocation with the collocations that the routing function names, and compare each row'scluster_db_nameandcluster_table_namewith the tables on that member cluster (direct). -
With the AWS CLI or the console, read the member cluster's status, and the events of the member cluster and of the group from when the failures started. For more information, see Working with Amazon RDS event notification and Amazon RDS events for database cluster groups for Aurora.
# Runs at: AWS CLI. The member cluster's status and engine version. aws rds describe-db-clusters --regionREGION--db-cluster-identifierMEMBER_CLUSTER_ID\ --query 'DBClusters[0].[Status,EngineVersion]' --output text # Runs at: AWS CLI. The group's events for the last 60 minutes. aws rds describe-events --regionREGION--source-type db-cluster-group \ --source-identifierGROUP_ID--duration 60 --query 'Events[].[Date,Message]' --output text -
On each instance of the member cluster, read the recent warnings and errors in its logs, as described in Monitoring Amazon Aurora log files.
-- Step 1. Runs at: routing endpoint, once per mapped database or table. SELECT 1 FROMROUTER_DB.ROUTER_TABLELIMIT 1; -- For a scaleout table, read one key from each collocation. Send the key bare. SELECT 1 FROMROUTER_DB.ROUTER_TABLEWHEREROUTING_KEY=KEY_VALUELIMIT 1; -- Step 1. Runs at: member cluster endpoint (direct). SELECT 1 AS reachable; -- Step 2. Runs at: routing endpoint, outside a transaction. SET SESSION router_cluster_pin = 'MEMBER_CLUSTER_ALIAS'; SELECT @@server_id; SET SESSION router_cluster_pin = DEFAULT; -- Step 3. Runs at: member cluster endpoint (direct). Sessions by connection source. SELECT IFNULL(src.ATTR_VALUE, '(none)') AS connection_source, COUNT(*) AS sessions FROM performance_schema.threads t LEFT JOIN performance_schema.session_connect_attrs src ON src.PROCESSLIST_ID = t.PROCESSLIST_ID AND src.ATTR_NAME = '_rds_connection_source' WHERE t.TYPE = 'FOREGROUND' AND t.PROCESSLIST_ID IS NOT NULL GROUP BY connection_source; -- Step 6. Runs at: each instance endpoint of the member cluster (direct). -- Recent warnings and errors since the last restart. SELECT LOGGED, PRIO, ERROR_CODE, LEFT(DATA, 200) AS message FROM performance_schema.error_log WHERE PRIO IN ('Warning', 'Error') ORDER BY LOGGED DESC LIMIT 50;
The Step 3 read needs performance_schema turned on for the instance. For the connection attributes, see The global connection ID.
Cause and fix. Match what the checks found to a row in the following table.
| Cause | Fix |
|---|---|
| It recently joined the group | member_cluster_mappings doesn't list a member cluster that is still joining until it can route. Wait until the table lists its alias and a pin to it answers, then retry. If the table lists it and its writer is available, but a pin still doesn't answer after several minutes, contact AWS Support. Include the DB cluster identifier and the group identifier |
| The member cluster user doesn't exist on it | Each routed statement runs on the member cluster as the member cluster user of the same name. If that user doesn't exist there, routed statements for that user fail. On Aurora MySQL they return error 1045 with (no matching account on cluster) at the end of the message. Create the user and its grants on the member cluster (direct). For more information, see Router users and routing layer privileges |
| It's failing over or restarting, including a restart after a parameter group change | Queries routed to it return errors until Aurora completes the failover, while queries to other member clusters continue. Reconnect and retry the transaction. Sessions that were open at the restart ended. After the restart, run one routed read for each mapping on it before you rely on it |
| It has no replica, and its writer failed | A member cluster with no replica stays unavailable until Aurora replaces its writer. Queries for its data fail until then, and queries for data on other member clusters keep running. To shorten this, add a replica to each member cluster. For more information, see Adding Aurora Replicas to a DB cluster |
| Its only writer instance was deleted | Routed statements for its data fail, and mapping changes that name it are refused, until it has a writer again. Create a DB instance in the same DB cluster. The member cluster routes again with no other change after the new writer is available. Then check a pin and the routed reads |
| It was stopped | Routed statements to it fail until it's started and available again. Start the DB cluster, and then check a pin and one routed read for each mapping on it. Write mapping changes that name it only after that. Don't remove it from the group to fix this |
| It was upgraded or patched | After it's available on the new version, check a pin and one routed read for each mapping on it before you rely on it. For more information, see Upgrading a group |
| The group was restored | Check each restored member cluster's settings and its writer, as described in Restoring a group. Then, after the group is available, check a pin and the routed reads |
| You turned routing off and on again | Disabling routing ends every routed session. With the AWS CLI, run aws rds describe-db-cluster-groups to check that the group is available again. Then, at the routing endpoint, check a pin and one routed read for each mapping on each member cluster. If they don't answer, contact AWS Support with the group identifier and the time that you enabled routing. Keep routing enabled for a group that serves traffic. For more information, see Enabling or disabling routing |
| A data mapping names a collocation that the routing function doesn't cover | Correct the data mapping or the routing function so that the routing function covers every collocation. For more information, see Changing data mappings |
| A mapping row names a table that doesn't exist on that member cluster | The group doesn't check the table on the member cluster when you write a mapping. Create the table on the member cluster, or correct the mapping row |
| You removed it while mappings still named it | A removal doesn't check data mappings, so routed statements to its objects fail after the removal. Before you remove a member cluster, move every object that a data mapping or a scaleout table places on it to another member cluster. For more information, see Adding and removing member clusters. To recover, add the DB cluster to the group again with the AWS CLI, and confirm that a pin to its alias answers at the routing endpoint. Then, at the routing endpoint, point each affected collocation at it with one UPDATE dbclustergroup_sys.data_mappings ... WHERE router_collocation_group = ' statement |
When a member cluster has no available writer, because it's stopped, failing over or restarting, or its writer instance failed or was deleted, routed statements to it fail with error 1429, 1105, or 1053, and statements to the other member clusters keep running. The routing layer sends routed statements only to a writer instance of the member cluster. When the writer is available again, for example after you start a stopped member cluster, the routing layer routes to it again without a change to the data mappings. Sessions that were routed to it when it stopped have ended, so reconnect them.
After every fix, check a pin and one routed read per mapping on new connections. Until both succeed, don't write a mapping that names the member cluster or start a move onto it.
If the error persists after the fix that matches, check whether anything else changed on the member cluster, such as its parameter group or a restart. Reconnect and run the routed read again. If it still fails, collect the time and the DB cluster identifier, and contact AWS Support.
Every client stalls or slows down
Symptom. Every client that uses the routing endpoint stalls in the same second, or latency rises everywhere. The errors are the clients' pool timeouts, not routing or connection errors. If only one member cluster's routed statements fail with error 1105, see A member cluster is unreachable through the routing endpoint instead.
Check. Before you change anything, find out whether one member cluster stops responding or the routing layer stalls. Check each member cluster directly, and compare it with the routing endpoint. On each member cluster (direct), also check its load and its sessions against max_connections, as in Connecting fails, is slow, or drops. At the routing endpoint, read the routing layer's process list to see which statements wait and on which member cluster.
To find whether a member cluster or the routing layer stalls
-
From the same client hosts, run the following three checks every second or so, for as long as the stall lasts or through its next occurrence. Keep the three series side by side with timestamps, one column for each member cluster.
-
A
SELECT 1at the routing endpoint, which the routing layer answers itself -
A routed read of one small table on each member cluster, at the routing endpoint
-
A
SELECT 1on each member cluster (direct)
-
-
On each member cluster (direct), record its running threads with the same timestamps. Running threads pile up on a member cluster that stops responding.
-
Match the series to a row in the table that follows the statements.
-
On a member cluster that stops responding, check its memory. With Enhanced Monitoring, look for swap activity while its CPU is idle. A member cluster that returns error
1041is short of memory. Read Enhanced Monitoring on every member cluster, not only the suspect one. Turning on Enhanced Monitoring modifies the instance, so turn it on before you need it. For more information, see Monitoring OS metrics with Enhanced Monitoring. -
With the AWS CLI or the console, read the events of that member cluster for a restart, a failover, or a capacity change, as described in Working with Amazon RDS event notification.
-
On every member cluster (direct), compare the session counts and connection counters from immediately before the stall started. A burst of connections that open or close on every member cluster at the same moment points at connection churn.
On Aurora MySQL, the checks are the following statements.
-- Step 1. Runs at: routing endpoint. The routing layer answers this itself. SELECT 1; -- Step 1. Runs at: routing endpoint. One small mapped table on each member cluster. SELECT 1 FROMROUTER_DB.ROUTER_TABLELIMIT 1; -- Step 1. Runs at: member cluster endpoint (direct), for each member cluster. SELECT 1 AS reachable; -- Step 2. Runs at: member cluster endpoint (direct), for each member cluster. SHOW GLOBAL STATUS LIKE 'Threads_running'; -- Step 6. Runs at: member cluster endpoint (direct), for each member cluster. SHOW GLOBAL STATUS LIKE 'Aborted_%'; SHOW GLOBAL STATUS LIKE 'Connection_errors%'; SELECT @@max_connections AS max_connections, (SELECT COUNT(*) FROM performance_schema.threads WHERE TYPE = 'FOREGROUND') AS foreground_threads;
The following table shows what the three series point at.
| The checks show | Points at |
|---|---|
| One member cluster's direct check is slow for as long as the stall, and its routed read is too. The other member clusters stay fast | That member cluster stops responding |
Every direct check stays fast, but the routed reads and the SELECT 1 at the routing endpoint stall or fail |
The routing layer |
| Every member cluster stays fast, but the application sees latency rise | The routing layer or the client. Read the routing layer's signals in Routing layer metrics and signals |
| One member cluster fails after it restarted | That member cluster. See A member cluster is unreachable through the routing endpoint |
Cause. The routing layer opens a member cluster session for each routed session, and it doesn't queue clients without limit. When a member cluster can't take a new session, the client gets an error instead of waiting without end. On Aurora MySQL, if the member cluster isn't accepting new sessions, the client gets error 1053 (SQLSTATE 08S01) Member cluster is not accepting new sessions; reconnect and retry the statement, and the routing layer closes the connection. If the member cluster can't be reached, the client gets error 1105 (HY000) Member cluster unavailable; reconnect and retry the statement, and the routing layer closes the connection. If the member cluster session doesn't finish opening within its time limit, the client gets error 1053 (SQLSTATE 08S01) Member cluster session did not open in time; reconnect and retry the statement, and the routing layer closes the connection. If the routing layer's wait for a member cluster connection runs out first, the statement fails with error 9501 (HY000) Timed-out waiting to acquire database connection, and the connection stays open, so retry the statement. Retry with backoff, and reduce the number of client connections that reach that member cluster. A busy or saturated member cluster also shows up as pool acquisition timeouts in every client that reaches it. If part of the routing layer fails, the clients connected to it lose their sessions and reconnect to the routing endpoint, while other clients keep running.
When everything is slow but nothing fails, first check whether one member cluster stops responding. A stall on one member cluster stalls the client pools that it shares with the other member clusters, while the routing layer keeps serving the other member clusters. The following causes can pause a member cluster or stall its clients:
-
Memory pressure. Swapping can pause a member cluster. Its CPU is idle, its direct checks are as slow as the stall, and its running threads pile up. During the stall, the per-minute change in
AuroraSlowHandshakeCountrises on the paused member cluster only. While a member cluster is paused, new connections to it still open, but each takes about as long as the stall. Statements already sent finish late, and none fail. -
A large capacity change. A large Aurora Serverless v2 scale-up during load can pause a member cluster.
-
A restart or failover. The member cluster's events show it.
-
Connection churn. A burst of reconnects after many connections close at once can briefly stall routing, because each reconnect needs a new member cluster session. A stall caused by a burst of new connections ends when the burst stops.
-
A repeating freeze. A freeze can repeat on a fixed period that equals the pool's idle timeout. The catch-up after a freeze uses every connection, so the connections then reach their idle timeout together.
Fix. Relieve the member cluster that the waiting statements reach, for example by ending a long transaction or by adding capacity. Size each pool against the member clusters that it reaches. For more information, see Managing connections. After part of the routing layer fails, reconnect and retry. Then match the cause to a row in the following table.
| Cause | Fix |
|---|---|
| One slow member cluster stalls every request | Bound every pool, set statement timeouts, and give independent workloads separate pools. For more information, see Configuring connection pools and Setting timeouts |
| Connections open or retire together on every member cluster | Add jitter to idle timeouts and maximum lifetimes, and fill pools gradually. For more information, see Idle close and connection lifetime |
| A small elastic pool that starts at full rate grows at once | Warm pools to the expected size, or ramp the request rate. For more information, see Running a test workload |
| An application deployment replaces every client at once | Roll deployments one instance at a time, and retire an old instance only after traffic has moved to the new one |
| Memory pressure on one member cluster | Raise its capacity range ahead of load, one change at a time. For more information, see Performance and scaling for Aurora serverless |
| A large capacity change |
Change capacity well before the load, not during it. Wait until one capacity change finishes before you start another on the same member cluster. To check whether a capacity change is still applying, read the member cluster's status and pending changes with the AWS CLI. Wait until
|
| A freeze repeats at the pool's idle timeout | Add jitter to the pool's idle sweep |
If the routing layer stalls while every member cluster stays fast, collect the times, the three check series, and the group identifier, and contact AWS Support.
If every client gets error 3168 (HY000) The database cluster group metadata is temporarily unavailable at the same time, the routing layer can't reach the group's metadata. Routed statements whose routing information the routing layer already holds in its cached metadata usually keep running. Reads of the dbclustergroup_sys tables and mapping changes always fail until the metadata is reachable again, whichever member cluster they concern. Retry with backoff. If the error persists, collect the times and the group identifier, and contact AWS Support.
A statement is slow or blocked
If one routed statement is slow, waits on a lock, or fails with a lock wait timeout, see Troubleshooting slow queries, long-running statements, and lock waits. That page finds the statement at the routing endpoint and on its member cluster, follows a lock wait to its blocker, and shows how to end a statement or a session.