

# Troubleshooting routing and data mappings

The routing layer of a database cluster group for Aurora sends each routed statement to one member cluster, as the data mappings and scaleout tables say. Most routing problems come from how a name or a key resolves, so check the name, the key as sent, the session, and the mapping, in that order. For the code and text of each error, see [Routing and data mapping errors](databaseclustergroups-errors-routing.md).

To see where a statement goes, run `EXPLAIN` at the routing endpoint. It runs on the target member cluster, and the routing layer adds its routing decision above the member cluster's plan. Compare it with the mapping rows. For more information, see [EXPLAIN](databaseclustergroups-sql-explain.md).

## A statement is refused
<a name="databaseclustergroups-a-statement-is-refused"></a>

**Symptom.** The routing layer returns Aurora MySQL error `1235` and runs the statement on no member cluster. Retrying it unchanged returns the same error.

**Check.** Find the error in [Routing and data mapping errors](databaseclustergroups-errors-routing.md), and then find the statement in the following table. For which statements the routing layer runs, see [Statement compatibility](databaseclustergroups-compatibility.md).

**Cause.** Through the routing layer, each statement and transaction runs on one member cluster. The routing layer refuses a statement that needs more than one, that has no usable routing key, or that it doesn't run in query routing mode. Every refused statement runs unchanged on a pinned session or a direct connection to the member cluster. For distributed queries and transactions, Aurora DSQL is a complementary option.

**Fix.** Find the refused statement in the following table.


| Refused statement | Fix | 
| --- | --- | 
| A join, a write, or a multi-row insert whose rows resolve to more than one member cluster | Add the routing key so that it reaches one member cluster, or send one statement for each member cluster and combine the results. Group a multi-row insert by member cluster. For a HASH routing function, send one row in each INSERT | 
| A statement in a transaction that reaches a second member cluster | Run ROLLBACK, and keep each transaction on one member cluster. For more information, see [Sessions, transactions, and session pinning](databaseclustergroups-sessions.md) and [Running queries and transactions through the routing layer](databaseclustergroups-queries.md). The details after this table show what happens to the transaction | 
| A statement on a scaleout table with no usable routing key | Add the key as = or IN, sent bare as a literal of the column's type. To count all rows, count on each member cluster and add the results | 
| A range that no single collocation contains, a pattern such as LIKE, a null test such as IS NULL, a negation such as <> or NOT IN, or a function on the routing key | Equality and IN always resolve a routing key. A range resolves only under a COLUMN routing function with VALUES IN RANGE collocations, when one collocation's range holds the whole range, so give a range both ends inside one collocation. Otherwise, pass the key with = or IN as a literal, and put other filters on columns outside the routing key. For the range predicates that resolve, see [Statements that resolve to one member cluster](databaseclustergroups-scaleout-tables.md#databaseclustergroups-how-data-distribution-works) | 
| An UPDATE of the routing key, or one that moves a row to another member cluster | You can't update a routing key column. Delete the row, and insert it again with the new key | 
| A statement that names a scaleout table and a table under a table-level mapping | Join in the application, or make both tables scaleout tables that use one routing function | 
| DDL | Run the DDL on each member cluster with cluster names, directly or through a session pin. For more information, see [Running DDL through a session pin](databaseclustergroups-schema-changes.md#databaseclustergroups-pin-ddl) | 
| A statement type that the routing layer doesn't handle | Run it on the member cluster, directly or through a session pin | 
| A filter or ORDER BY on a dbclustergroup\_sys table that it doesn't accept | Read with one equality or one tuple equality, or read the whole table and filter and sort it in your client. For more information, see [System tables for database cluster groups for Aurora](databaseclustergroups-system-views.md) | 

After the routing layer refuses a statement in a transaction for reaching a second member cluster, the transaction stays open on the first member cluster. Run `ROLLBACK`: a `COMMIT` commits the statements that ran before the refused one. Text and binary-protocol prepared statements work on a scaleout table. The routing layer routes each execute by the routing key value bound for that execute.

A data access permission error comes from the member cluster, which enforces data privileges. For one user, a missing grant returns `1142`. Read the user's grants on each member cluster (direct) with `SHOW GRANTS`.

If statements fail for one user, or right after a move, create the missing member cluster user or grant on each member cluster that lacks it. This includes a move target, because a move doesn't create users. Also check the user name for leading or trailing spaces. For more information, see [Router users and routing layer privileges](databaseclustergroups-router-users.md). If a new scaleout table fails, check for a collocation that the routing function leaves out. The group doesn't check that a mapping row's table exists on its member cluster, so compare `cluster_db_name` and `cluster_table_name` with the member cluster's tables.

A statement that the routing layer resolves but can't deliver isn't refused: on Aurora MySQL, it returns error `1429` (no healthy endpoint), `1105`, or `1053` (08S01) when the member cluster doesn't accept or open the session in time. For the ordered checks, see [A member cluster is unreachable through the routing endpoint](databaseclustergroups-ts-stalls.md#databaseclustergroups-a-member-cluster-is-unreachable-through-the-router). To check a new setup step by step, see [Before you start: what to collect](databaseclustergroups-troubleshooting.md#databaseclustergroups-before-you-start-troubleshooting).

## Wrong rows, or rows from an unexpected member cluster
<a name="databaseclustergroups-wrong-or-surprising-results"></a>

**Symptom.** A statement returns no rows, rows from an unexpected member cluster, a value that differs from a direct connection, or a retryable error right after a mapping change.

**Check.** At the routing endpoint, compare the `EXPLAIN` target with the router name's mapping row or the scaleout table's routing function. The statements follow the table.

Then check the following, in order. On Aurora MySQL, the statements for each check follow the table.

1. **Is the name mapped?** At the routing endpoint, look up the router name in `data_mappings`. Then, on the member cluster that the row names (direct), confirm that the database and table exist. The group doesn't check that they exist.

1. **Is the key sent bare, as its column's type?** In the client, check how the driver binds the key. Send the key bare, as a literal of its column's type.

1. **Does the session carry a pin?** At the routing endpoint, read `pin_status` and `member_cluster_alias` in `router_processlist`. For the columns, see [Process list table: router\_processlist](databaseclustergroups-sysviews-router-processlist.md).

1. **Did the routing change?** At the routing endpoint, read the scaleout table and routing function definitions back, and compare them with your export. A routing function switch moves no rows, so the routing layer can stop finding existing rows by their key.

1. **Are rows on the wrong member cluster?** On a clone of each member cluster (direct), count the rows of a member table whose key routes to another collocation. A row that a direct connection or a pin wrote there can't be read through the routing endpoint.

1. **Is a scaleout table name reused?** At the routing endpoint, list the scaleout table names with `SHOW SCALEOUT TABLES`. For more information, see [SHOW SCALEOUT TABLES](databaseclustergroups-sql-show-scaleout.md).

1. **Do string keys match byte for byte?** On each member cluster (direct), compare the key column's type, character set, and collation on every member table.

1. **Did a mapping change?** At the routing endpoint, compare `data_mappings` with your last export, and check that each object exists, with its rows, on the member cluster that its row names.

**Cause and fix.** Find what you see in the following table or the details that follow.


| You see | Cause | Fix | 
| --- | --- | --- | 
| A statement fails with Aurora MySQL 1412 right after a mapping change, or after the cutover of a move | The statement was routed on the older mapping. On Aurora MySQL, the routing layer resends a text-protocol statement up to 3 times first, then returns 1412 with the statement not run and the session intact. If the statement was in an open transaction, the transaction ends, so retry the whole transaction. For when a change reaches the routing layer, see [Applying data mapping changes](databaseclustergroups-data-mappings.md#databaseclustergroups-when-a-data-mapping-change-takes-effect) | Retry. A retry routes on the new mapping. On Aurora MySQL, retry the statement | 
| A statement fails with Aurora MySQL 63928 (SQLSTATE 40001) inside a transaction | A mapping or definition changed after the transaction's first routed statement, and the routing layer already rolled the whole transaction back. For the retry rule, see [Transaction errors and retries](databaseclustergroups-sessions.md#databaseclustergroups-when-a-mapping-change-reaches-an-open-transaction) | Retry the whole transaction from its first statement; don't send COMMIT. If the session holds server-side prepared statements, the routing layer closes the connection instead: reconnect and run the whole transaction again | 
| A lookup by key returns nothing, but the row is on a member cluster | The client sent the key quoted or as another type, the routing function changed, or a write put the row on a member cluster that its key doesn't map to | Bind the key as its column's type and send it bare. A routing function switch moves no rows. On a clone, count rows whose key routes elsewhere | 
| Two rows for one key, on two member clusters | A write after a routing function switch, or a write to a member table on a direct connection or a session pin, which bypasses routing | Stop writes to member tables over direct connections and pins. Repair the rows so that each is on the member cluster that its key maps to, before you rely on reads of those keys | 
| An empty result in one session only | The session carries a session pin to another member cluster | Clear the pin when the pinned work is done | 
| Reads of a scaleout table return another database's rows | Two databases reuse one scaleout table name. Scaleout table names are group-wide | Give every scaleout table a name that no other database uses | 
| A mapping change pointed reads at the wrong place | A wrong mapping write. No API restores mappings on their own | Restore the rows from the export that you take before and after each change. For more information, see [Exporting the mappings before and after a change](databaseclustergroups-changing-mappings.md#databaseclustergroups-export-mappings) | 
| A unit of work rolled back, but some writes stayed | On Aurora MySQL, the application sent COMMIT after a refused statement in a transaction | After a refused statement in a transaction, run ROLLBACK | 
| A table-less read of the version or a variable doesn't match the member cluster | The routing layer answers some table-less reads itself, with the session's value or its own | Read a member cluster's setting in a routed statement, or on the member cluster directly | 

```sql
-- Runs at: routing endpoint. Read-only for SELECT; EXPLAIN ANALYZE changes no rows.
EXPLAIN SELECT * FROM {{ROUTER_DB}}.{{ROUTER_TABLE}} WHERE {{ROUTING_KEY}} = {{KEY_VALUE}};

-- Runs at: routing endpoint. Read the whole table; filter in your client.
SELECT * FROM dbclustergroup_sys.data_mappings;
```

To clear a pin, run `SET SESSION router_cluster_pin = DEFAULT;`. A table-less read is, for example, `SELECT VERSION()` or `SELECT @@{{variable}}`.

The following statements run the checks in order. Filters on the `dbclustergroup_sys` tables take literal values only.

```sql
-- 1. Runs at: routing endpoint. Router name to cluster name, for a table-level and a database-level router name.
SELECT * FROM dbclustergroup_sys.data_mappings
 WHERE (router_db_name, router_table_name) = ('{{ROUTER_DB}}', '{{ROUTER_TABLE}}');
SELECT * FROM dbclustergroup_sys.data_mappings WHERE router_db_name = '{{ROUTER_DB}}';

-- 1. Runs at: routing endpoint. Cluster name to router name, when you start from a name on a member cluster.
SELECT * FROM dbclustergroup_sys.data_mappings WHERE cluster_db_name = '{{CLUSTER_DB}}';

-- 1. Runs at: member cluster endpoint (direct), on the member cluster that the row names.
SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.TABLES
 WHERE TABLE_SCHEMA = '{{CLUSTER_DB}}' AND TABLE_NAME = '{{CLUSTER_TABLE}}';

-- 3. Runs at: routing endpoint. Read the whole table; filter on pin_status in your client.
SELECT * FROM dbclustergroup_sys.router_processlist;

-- 4. and 6. Runs at: routing endpoint, in a session without a pin.
SHOW SCALEOUT TABLES;
SHOW CREATE SCALEOUT TABLE {{ROUTER_DB}}.{{TABLE}};
SHOW CREATE SCALEOUT ROUTING FUNCTION {{ROUTING_FUNCTION}};
```

To count rows on the wrong member cluster (check 5), run the following on a clone of the member cluster, or on a reader of it (direct), one primary key range at a time. Take the buckets of each member table from your routing function definition. The statement is for a `MOD` routing function.

```sql
-- 5. Runs at: a clone or a reader of the member cluster (direct). MOD: rows outside the member table's buckets.
SELECT /*+ MAX_EXECUTION_TIME(10000) */ COUNT(*) AS rows_on_wrong_member
FROM {{CLUSTER_DB}}.{{MEMBER_TABLE}}
WHERE {{PK}} >= {{LOW}} AND {{PK}} < {{HIGH}}
  AND MOD({{ROUTING_KEY}}, {{N}}) NOT IN ({{BUCKETS}});

-- 7. Runs at: member cluster endpoint (direct), on each member cluster.
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, CHARACTER_SET_NAME, COLLATION_NAME
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = '{{CLUSTER_DB}}' AND COLUMN_NAME = '{{ROUTING_KEY}}';
```


| You see | Cause | Fix | 
| --- | --- | --- | 
| 1146 for a name that the application uses | The table isn't in the routing metadata of the group | Look up the router name in data\_mappings, and map the name or fix the mapping | 
| Date and time values differ by member cluster | Direct connections use each member cluster's time zone, and routed sessions on Aurora MySQL use the routing endpoint time\_zone parameter, \+00:00 by default | Set time\_zone in the session or the routing endpoint parameter, and keep the time zone the same on every member cluster for direct connections. A session-level SET applies on each member cluster that the session reaches | 
| String keys that look equal route or read differently | The keys differ in invisible characters, Unicode normalization, or length, or the key column's type, character set, or collation differs between member tables | Clean the keys, use one type and collation for the key column on every member table, and run with a strict sql\_mode, so that a write that would truncate a key fails | 

On Aurora MySQL, every routed session uses `utf8mb4`, so the client character set can't make a string key route differently between clients. The routing endpoint refuses a client that connects with another character set, such as `latin1`, with error `1115`, and refuses `SET NAMES` with another character set with error `1115` (`Unknown character set: 'latin1'`). The session collation doesn't change routing either: the routing layer compares a string key under the routing key's collation, or, under a `*_normalized` `HASH` algorithm, normalizes it whatever the collation. For more information, see [Collations and string routing keys](databaseclustergroups-character-sets.md#databaseclustergroups-character-sets-routing-keys).

## A session behaves differently through the routing endpoint
<a name="databaseclustergroups-a-session-behaves-differently-through-the-router"></a>

**Symptom.** A session setting, a variable, a pooled connection, or a session pin behaves differently than on a direct connection to a member cluster.

**Check.** Read the value in the session at the routing endpoint, in a routed statement, and on the member cluster (direct). For what the routing layer answers itself, see [Variables, character sets, and statements the routing layer answers](databaseclustergroups-session-variables.md). For pins, see [Session pinning](databaseclustergroups-sessions.md#databaseclustergroups-session-pinning).

**Cause.** The routing layer keeps one session for the client and opens member cluster sessions behind it. It replays the session's settings on each member cluster that the session reaches, and answers some statements itself.

**Fix.** Find the behavior in the following table or the details that follow.


| Behavior | Fix | 
| --- | --- | 
| A variable that the session and the routing layer don't set runs under each member cluster's own value | Keep member cluster parameters the same, and set the values that you rely on in the session | 
| A pinned session passes statements through to its member cluster. Router names and scaleout tables aren't reachable, and a write to a member table bypasses routing. Temporary objects on the member cluster don't block the return to routing | Use cluster names, keep each row on the member cluster that its key maps to, and clear the pin outside a transaction when the work is done | 
| A name that resolved before a pin or unpin doesn't resolve after it | A pin first runs USE of the pin's database part, or of the session's current database, on the member cluster. If that name isn't a database there, the pin is refused and the session stays as it was. Name the cluster database in the pin, as in 'alias@cluster\_db'. After an unpin, the current database keeps its value, so run USE with a router name before the next routed statement | 
| A pin or unpin is refused | A pin can't change inside an open transaction. Commit or roll back, and then pin or unpin with SET SESSION, not SET GLOBAL or SET LOCAL | 
| A pooled connection carries another request's session settings | Reset session state when the pool returns a connection, or set the session values on borrow | 

The routing layer holds a session's `SET` statements and applies them on each member cluster that the session reaches. This includes `SET SESSION TRANSACTION ISOLATION LEVEL`. `SET TRANSACTION` before `BEGIN` sets the level for the next transaction only.

A pin change inside a transaction returns `1179`. With `autocommit = 0`, the first read or write opens a transaction. Clear a pin with `SET SESSION router_cluster_pin = DEFAULT;` outside a transaction. A `USE` of an unmapped router database name doesn't fail when you run it, and the first statement after it fails instead.

For connection drops after an idle period, see [Connecting fails, is slow, or drops](databaseclustergroups-ts-connections.md#databaseclustergroups-connecting-fails-or-is-slow).

## Fixing errors by code
<a name="databaseclustergroups-ts-routing-error-fixes"></a>

The following sections give what to do for each routing, scaleout table, and session error, by its code and a short form of its message. For how to read an error from the routing endpoint, see [Using error codes to troubleshoot](databaseclustergroups-troubleshooting.md#databaseclustergroups-ts-using-error-codes).

### Fixing routing and data mapping errors
<a name="databaseclustergroups-ts-routing-error-fixes-routing"></a>

The following table lists routed statements first, and then writes to the data mappings. For the message text and cause of each error, see [Routing and data mapping errors](databaseclustergroups-errors-routing.md).


| Aurora MySQL code (SQLSTATE) | Error | What to do | 
| --- | --- | --- | 
| 1235 (42000) | The statement reaches more than one member cluster | To see the member cluster that each part of the statement reaches, run EXPLAIN on each part at the routing endpoint. Use routing key values that resolve to one member cluster, or send one statement for each member cluster and combine the results in the application. See [Checking which member cluster a statement reaches](databaseclustergroups-queries.md#databaseclustergroups-queries-explain). | 
| 1235 (42000) | The transaction reaches a second member cluster | Run ROLLBACK, and retry the whole transaction. On Aurora MySQL, a COMMIT commits the statements that ran before the rejected one. Run the statement for the other member cluster in its own transaction. See [Sessions, transactions, and session pinning](databaseclustergroups-sessions.md). | 
| 1235 (42000) | Queries referencing both Scaleout Tables and Router Tables in the same statement are not supported. ... | Run two statements and combine the results in the application, or make the second table a scaleout table too. | 
| 1235 (42000) | Cannot resolve routing target: insufficient routing information | Add an equality or IN on the routing key, with literal values. Compute other values in your application. | 
| 1235 (42000) | Unsupported predicate value type for routing key | Pass the routing key as a literal. | 
| 1235 (42000) | Operator '...' is not supported on routing key columns, or Range predicate on table '...' is not supported, or ... is not fully contained in a single collocation | Use = or IN on the routing key. A range resolves only under a COLUMN routing function with VALUES IN RANGE collocations, when one collocation's range holds the whole range. Otherwise, put the filter on columns outside the routing key. For the range predicates that resolve, see [Statements that resolve to one member cluster](databaseclustergroups-scaleout-tables.md#databaseclustergroups-how-data-distribution-works). | 
| 1235 (42000) | UPDATE of routing key column '<column>' is not allowed | Delete the row, and insert it again with the new key. | 
| 1235 (42000) | No collocation matched the evaluated routing function result, or the constant isn't valid for the routing function | Use a key that the routing function covers. To cover more values, create the routing function again with full coverage. | 
| 1235 (42000) | Required routing key column '<column>' not found in the column list | Include the routing key in the column list. | 
| 1235 (42000) | Routing key column '<column>' has an invalid position in metadata | List the columns in the INSERT. Or give each key column its position with ALTER SCALEOUT TABLE {{table\_name}} ROUTE BY KEY({{column}} POSITION({{n}})), which keeps the routing function. | 
| 1235 (42000) | No member cluster could be resolved for this query | Read dbclustergroup\_sys.data\_mappings for the objects that the statement names. Name a mapped object in the statement, or give the routing key of the scaleout table. To see the member cluster that the routing layer selects, put EXPLAIN in front of the statement at the routing endpoint. | 
| 1235 (42000) | This operation is not supported in query routing mode. Use the cluster endpoint directly or pin the session to a member cluster. | Connect to the endpoint of the member cluster, or pin the session to a member cluster. Then run the statement again with cluster names. See [Running DDL through a session pin](databaseclustergroups-schema-changes.md#databaseclustergroups-pin-ddl). | 
| 1235 (42000) | Aurora MySQL: This statement type is not supported | Run the statement on the member cluster, through its own endpoint or a session pin. | 
| 1235 (42000) | An unsupported query on a dbclustergroup\_sys table. The message names the unsupported part | Rewrite the filter as a single equality, for example WHERE (router\_db\_name, router\_table\_name) = ('<db>', '<table>'), or read the whole table and sort it in your client. | 
| 1235 (42000) | Joining '<catalog object>' with '<db.table>' is not supported | Query the catalog and the table in separate statements. | 
| 1064 (42000) | Aurora MySQL: a request that holds more than one statement returns a syntax error | On Aurora MySQL, send one statement in each request, or turn on the client's multi-statement option (CLIENT\_MULTI\_STATEMENTS, for example allowMultiQueries=true in MySQL Connector/J). With that option on, the routing layer runs the statements one at a time, and each routes on its own, up to 256 statements in a request. Without it, the request returns error 1064, as on an Aurora DB cluster. The 1235 message, Multiple statements in a single request are not supported, comes only from a single-statement parse, such as the inner text of a SQL PREPARE. | 
| 1243 (HY000) | Unknown prepared statement handler | Prepare the statement again. In a pinned session, prepare statements after the pin. You don't need to turn off server-side prepared statements. | 
| 1105 (HY000), 1429 (HY000), or 1053 (08S01) | An internal error occurred while processing the statement. or Member cluster unavailable; reconnect and retry the statement (1105), Member cluster is currently unavailable: no healthy endpoint (1429), or Member cluster is not accepting new sessions; reconnect and retry the statement or Member cluster session did not open in time; reconnect and retry the statement (1053) | Compare each mapping's collocation with the collocations that the routing function names, and each row's cluster\_db\_name and cluster\_table\_name with the tables on that member cluster. Check that the member cluster user exists on that member cluster. For the full check, see [A member cluster is unreachable through the routing endpoint](databaseclustergroups-ts-stalls.md#databaseclustergroups-a-member-cluster-is-unreachable-through-the-router). | 
| 1146 (42S02) | Aurora MySQL: Table '<name>' doesn't exist | Map the table, or use its current router name. On Aurora MySQL, if the error comes inside a transaction, run ROLLBACK first, because the transaction stays open. | 
| 1049 (42000) | Aurora MySQL: Unknown database '<name>' | Map the database. | 
| 1412 (HY000) | Aurora MySQL: Table definition has changed, please retry transaction | On Aurora MySQL, the routing layer resends a text-protocol statement up to 3 times first, then returns this error with the session intact. Retry the statement. If the statement was in an open transaction, the transaction ends, so retry the whole transaction. A retry routes on the new mapping. See [Applying data mapping changes](databaseclustergroups-data-mappings.md#databaseclustergroups-when-a-data-mapping-change-takes-effect). | 
| 63928 (40001) | Aurora MySQL: Aurora DB Cluster Group routing mappings referenced by this transaction have changed. Transaction rolled back. Please retry | Aurora MySQL, inside a transaction: the routing layer already rolled the transaction back. Retry the whole transaction from its first statement. If the session holds server-side prepared statements, the routing layer closes the connection instead: reconnect and run the whole transaction again. See [Transaction errors and retries](databaseclustergroups-sessions.md#databaseclustergroups-when-a-mapping-change-reaches-an-open-transaction). | 
| 1064 (42000) | Aurora MySQL: You have an error in your SQL syntax | Correct the statement. | 
| 1227 (42000) | Access denied; you need the 'DBCLUSTERGROUP\_METADATA\_ADMIN' privilege for this operation | Run the write as a router user that holds the privilege. | 
| 64004 (42000) | Member cluster '<alias>' doesn't exist (the alias isn't a member cluster alias) | Use an alias from member\_cluster\_mappings. | 
| 64021 (42000) | <Database\|Table> '<alias>' already has a data mapping | Choose another name, or change the existing mapping with UPDATE. | 
| 1235 (42000) | Reserved identifier ..., or Invalid character ... for a data mapping | Choose another name. | 
| 64062 (42000) | The collocation is already on another member cluster | Use the member cluster of that collocation, or a new collocation name for this member cluster. | 
| 64043 (42000) | The member cluster of a single data mapping can't change through its own row: member\_cluster\_alias can't be changed on one data mapping because '<mapping>' belongs to collocation group '<collocation>' | Move the whole collocation in one statement, with WHERE router\_collocation\_group = '<collocation>'. To move one mapping on its own, set member\_cluster\_alias and a new router\_collocation\_group in the same SET list. | 
| 1235 (42000) | db\_cluster\_identifier is read-only | Remove db\_cluster\_identifier from the column list or the SET list. Set member\_cluster\_alias instead. | 
| 1235 (42000) | Writes (INSERT/UPDATE/DELETE) on dbclustergroup\_sys.data\_mappings are not allowed inside a transaction (opened by BEGIN/START TRANSACTION or SET autocommit=0) | Commit or roll back, turn on autocommit (SET autocommit = 1), and then run the write as its own statement. | 
| 1235 (42000) | cannot remove data mapping '<db>.<table>': referenced by a scaleout table | Drop the scaleout table first, and then delete the mapping. | 

### Fixing scaleout table and routing function errors
<a name="databaseclustergroups-ts-routing-error-fixes-scaleout"></a>

The following table covers statements that create, change, or drop routing functions and scaleout tables. For the message text and cause of each error, see [Scaleout table and routing function errors](databaseclustergroups-errors-scaleout.md).


| Aurora MySQL code (SQLSTATE) | Error | What to do | 
| --- | --- | --- | 
| For example, 1064, 1305, 1480, 1481, 1488, 1491, 1493, 1495, 1517, or 1582 (42000 or HY000) | The routing layer refuses the routing function definition | Correct the definition. | 
| 1305 (42000) | FUNCTION <name> does not exist. Use <supported functions>. for an unknown routing function type | Use a routing function type that's available. See [routing function availability](databaseclustergroups-scaleout-tables.md#databaseclustergroups-routing-function-availability). | 
| 1491 | A parameter data type that the routing function can't use, for example MOD over a non-integer parameter, which returns the matching MySQL partitioning error | Use a parameter of a data type that the routing function supports. See [routing function availability](databaseclustergroups-scaleout-tables.md#databaseclustergroups-routing-function-availability). | 
| 1235 (42000) | Parameter data type is incompatible with the routing function type, for a parameter data type that MySQL accepts but the routing function can't use | Use a parameter of a data type that the routing function supports. See [routing function availability](databaseclustergroups-scaleout-tables.md#databaseclustergroups-routing-function-availability). | 
| 64005 (42000) | No data mapping declares the target collocation | Create the data mappings with that router\_collocation\_group first. | 
| 64022, 64025 (42000) | Routing function '<function>' already exists, or the scaleout table name equals a table alias | Choose another name. | 
| 64000 (42000) | Member '<member>' has no data mapping. Create a data mapping for it. | Create the table-level mapping first, and then use its router table name in MEMBER. | 
| 64040 (42000) | Member '<member>' already belongs to a scaleout table | Map a separate table for the new scaleout table, or drop the other scaleout table first. | 
| 64066 (42000) | Scaleout table '<table>' has no member in collocation group '<collocation>', which its routing function targets | Keep one member in each target collocation. | 
| 64024 (42000) | Scaleout table '<table>' already has a member in collocation group '<collocation>' | Give each member its own collocation. | 
| 64042 (42000) | Cannot drop routing function '<function>' referenced by scaleout tables | Drop the scaleout tables that use it first. | 

### Fixing session and transaction errors
<a name="databaseclustergroups-ts-routing-error-fixes-sessions"></a>

The following table covers session pins, session settings, ending a session, XA transactions on a pinned session, and writes during the cutover of a data movement job. For the message text and cause of each error, see [Session and transaction errors](databaseclustergroups-errors-sessions.md). For what to retry after each kind of error, see [Retrying after an error](databaseclustergroups-queries.md#databaseclustergroups-queries-retries).


| Aurora MySQL code (SQLSTATE) | Error | What to do | 
| --- | --- | --- | 
| 1179 (25000) | You are not allowed to pin in a transaction. COMMIT or ROLLBACK first. (unpin for an unpin) | Commit or roll back, and then pin or unpin. | 
| 64004 (42000) | Member cluster '<alias>' doesn't exist | Use an alias from member\_cluster\_mappings. | 
| 1231 (42000) | The router\_cluster\_pin value must be a quoted string, The router\_cluster\_pin variable takes a single value, or Member cluster and database name must both be non-empty | Pass a single single-quoted value that names both the member cluster alias and the database. | 
| 1049 (42000) | Unknown database '<db>', or The member cluster rejected the pin | Pin with '<MEMBER\_CLUSTER\_ALIAS>@<CLUSTER\_DB>', where the database is the cluster name on that member cluster. | 
| 3170 (HY000) | The member cluster is not accepting new sessions. Retry later. | Retry the pin later. | 
| 1429 (HY000) | The member cluster is unreachable | Fix the member cluster as described in [A member cluster is unreachable through the routing endpoint](databaseclustergroups-ts-stalls.md#databaseclustergroups-a-member-cluster-is-unreachable-through-the-router), and then pin again. | 
| 1049 or 1146 | Unknown database '<name>' or Table '<db>.<table>' doesn't exist in a pinned session | Use cluster names while the session is pinned. | 
| 63927 (HY000) | Aurora MySQL: Cannot write to <table> while data movement job '<job\_id>' is in progress | Retry the write. See [Moving data between member clusters](databaseclustergroups-data-movement.md). | 
| 1094 | The MySQL unknown thread error, returned for KILL | The session has already ended at the routing layer. If its locks remain, find the member cluster session by \_rds\_router\_connection\_id and run KILL on it (direct). See [A long-running statement or an idle session holds locks](databaseclustergroups-ts-slow-queries.md#databaseclustergroups-ts-slow-queries-long-running). | 
| 1179 | Returned when you clear a pin | End or prepare the XA transaction, and then clear the pin. | 
| 1399 | XAER\_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state, returned for XA COMMIT | Run XA END first. | 
| 1235 (42000) | Returned for an XA statement | Pin the session to the member cluster, or connect to its endpoint, and run the XA statements there. To end a prepared XA transaction after an unpin, pin to that member cluster again and run XA COMMIT or XA ROLLBACK. | 