View a markdown version of this page

System tables for database cluster groups for Aurora - Amazon Aurora

System tables for database cluster groups for Aurora

The routing layer of a database cluster group for Aurora keeps its metadata in system tables in reserved schemas. It answers queries on these tables from its own state, not from any member cluster. Query them at the routing endpoint, in an unpinned session, to see the member clusters, the data mappings, the sessions at the routing endpoint, the router users, and the data movement jobs. Each table has its own topic with its columns and example queries. To change the data mappings, see Data mapping statements. For session variables and the statements that the routing layer answers itself, see Variables, character sets, and statements the routing layer answers.

Where to query the system tables

The system tables exist only at the routing endpoint, not on any member cluster. In an unpinned session, the routing layer answers every statement on dbclustergroup_sys itself and never forwards it to a member cluster. The name dbclustergroup_sys is reserved in every letter case: a data mapping can't use it as a router name or a cluster name, and the routing layer rejects data definition statements on it.

A pinned session passes its statements through to its member cluster, so the system tables aren't visible there. The routing layer forwards a statement on dbclustergroup_sys in a pinned session to the member cluster, where it fails. For more information about pins, see Session pinning.

A read of a system table reaches no member cluster, so it shows the declared mappings but doesn't test routing. To test routing, query a mapped table by its router name.

Run each write to data_mappings outside a transaction. You can read a system table inside a transaction.

Connect to the routing endpoint in query routing mode. The tables are in two reserved databases, dbclustergroup_sys and dbclustergroup_data_movement. A session with autocommit = 0 counts as an open transaction.

System tables

The following table lists the system tables.

Table What it shows Write access
dbclustergroup_sys.member_cluster_mappings One row for each member cluster: its alias and the DB cluster it points at SELECT and UPDATE. The routing layer rejects INSERT and DELETE, because an alias comes from the group's member clusters
dbclustergroup_sys.data_mappings One row for each data mapping: which database, schema, or table is on which member cluster, under which router name, in which collocation Read and write. Writes to this table are how you change a mapping
Process list: dbclustergroup_sys.router_processlist The sessions at the routing endpoint Read only
dbclustergroup_sys.router_user_definition The router users and their privileges for database cluster groups for Aurora. It has no password column Read only
dbclustergroup_data_movement.move_info The state of one data movement job Read only

No system table lists your scaleout tables or your routing functions. Keep your own copy of each CREATE SCALEOUT ROUTING FUNCTION and CREATE SCALEOUT TABLE statement. Read them with SHOW SCALEOUT TABLES, SHOW CREATE SCALEOUT TABLE, SHOW SCALEOUT ROUTING FUNCTIONS, and SHOW CREATE SCALEOUT ROUTING FUNCTION. At the routing endpoint, information_schema lists a scaleout table under its own name, with the values of one member table. TABLE_ROWS, DATA_LENGTH, and the other statistics are that member table's values, not sums or averages.

Every column of dbclustergroup_sys.member_cluster_mappings, dbclustergroup_sys.data_mappings, and dbclustergroup_data_movement.move_info has the data type VARCHAR. In dbclustergroup_sys.router_user_definition, the username, host, authentication_method, privileges, and grantable_privileges columns are VARCHAR; account_locked, password_expired, and require_ssl are TINYINT(1); and password_expiry_interval_days is BIGINT. In dbclustergroup_sys.router_processlist, the id and time columns are BIGINT, and the user, host, db, command, state, info, member_cluster_alias, and pin_status columns are VARCHAR.

Visibility and privileges

Router users hold the privileges for database cluster groups for Aurora. The following privileges apply to the system tables:

  • A read of member_cluster_mappings or data_mappings needs dbclustergroup_metadata_read_only, dbclustergroup_metadata_admin, or dbclustergroup_super_admin.

  • A write to data_mappings needs dbclustergroup_metadata_admin.

  • The process list shows your own sessions to any router user. To see the sessions of other router users, you need dbclustergroup_process_admin. To end the sessions of other router users, you need dbclustergroup_connection_admin.

  • A read of router_user_definition needs dbclustergroup_user_admin.

  • dbclustergroup_super_admin carries every other privilege for database cluster groups for Aurora.

The other privileges for database cluster groups for Aurora are dbclustergroup_move_admin, for the data movement statements, and dbclustergroup_metadata_read_only, which reads data_mappings, member_cluster_mappings, and move_info without write access. For router users, member cluster users, and the full list of these privileges, see Router users and routing layer privileges.

A rename in member_cluster_mappings needs dbclustergroup_metadata_admin. A read of move_info needs dbclustergroup_metadata_read_only or dbclustergroup_move_admin.

Filters the system tables accept

The routing layer accepts a few query shapes on its system tables, with literal values only. Use a plain SELECT, and sort or filter further in your client. The routing layer rejects every other shape with error 1235 (SQLSTATE 42000) on Aurora MySQL. For the error codes, see Error codes for database cluster groups for Aurora.

The following table shows the query shapes on data_mappings. The same rules apply to the other system tables, except where a table's own topic says otherwise.

Shape Example Result
No WHERE SELECT * FROM dbclustergroup_sys.data_mappings Accepted
One equality, with a quoted literal WHERE member_cluster_alias = 'member-b' Accepted
One tuple equality WHERE (router_db_name, router_table_name) = ('app', 'orders') Accepted
COUNT(*) as the only select item SELECT COUNT(*) FROM … WHERE member_cluster_alias = 'member-a' Accepted
Plain columns and column aliases in the select list SELECT member_cluster_alias AS m FROM … Accepted
An expression, a subquery, or a variable as a value WHERE member_cluster_alias = UPPER('member-b') Rejected, with Only literal values are allowed. No expressions, subqueries, or variables.
AND or OR WHERE router_db_name = 'app' AND router_table_name = 'orders' Rejected, with AND/OR are not supported in the WHERE clause on this table. Use the tuple form
IN WHERE member_cluster_alias IN ('member-a', 'member-b') Rejected, with IN lists are not supported; use tuple equality
!=, <>, LIKE, IS NULL, or a range WHERE router_db_name LIKE 'app%' Rejected, with WHERE clause supports only column = 'value' or a tuple equality
ORDER BY … ORDER BY member_cluster_alias Rejected, with ORDER BY is not supported on this table
LIMIT n … LIMIT 100 Accepted
LIMIT n OFFSET m … LIMIT 100 OFFSET 200 Accepted
LIMIT m, n … LIMIT 200, 100 Accepted
Another LIMIT or OFFSET form, such as OFFSET without LIMIT, or a non-integer bound … OFFSET 10 Rejected, with LIMIT and OFFSET on this table take the forms LIMIT n and LIMIT n OFFSET m (and LIMIT m, n on MySQL), with non-negative integer literals
GROUP BY, HAVING, DISTINCT, or a locking read such as FOR UPDATE … GROUP BY member_cluster_alias Rejected, with a message that names the clause, for example GROUP BY and HAVING are not supported on this table
Any other function or expression in the select list, or COUNT(*) beside another item SELECT COUNT(1) … Rejected, with Functions and expressions are not supported in SELECT on this table (only COUNT(*) as the sole select item is allowed)
A join, a second table, or a subquery in FROM … JOIN dbclustergroup_sys.member_cluster_mappings … Rejected, for example with JOINs are not supported on this table

Tools that dump or introspect the system tables

The system tables exist only in the routing layer. No member cluster holds them, and they don't appear in information_schema. A read of information_schema.TABLES or information_schema.COLUMNS doesn't list them. A read filtered on dbclustergroup_sys or dbclustergroup_data_movement returns no rows. It doesn't fail. The routing layer reports every system table as BASE TABLE, including the tables that you can only read.

To inspect a system table, run SHOW [FULL] TABLES, SHOW TABLE STATUS, SHOW [FULL] COLUMNS, DESCRIBE, or SHOW INDEX at the routing endpoint, for example SHOW COLUMNS FROM dbclustergroup_sys.data_mappings. The routing layer answers these statements itself. It refuses SHOW CREATE TABLE, SHOW CREATE DATABASE, SHOW TRIGGERS, and EXPLAIN on a system table with error 1235.

A dump tool such as mysqldump can't dump the system tables, because the routing layer refuses the SHOW CREATE TABLE, LOCK TABLES, and SELECT /*!40001 SQL_NO_CACHE */ statements that the tool sends for them. Leave dbclustergroup_sys and dbclustergroup_data_movement out of a dump, for example by naming only your own databases. To dump your data, dump each member cluster through its own endpoint. To keep a copy of the mappings, export data_mappings and member_cluster_mappings with a plain SELECT that has no modifiers. For the procedure, see Exporting the mappings before and after a change.

Names, IDs, and consistency

Keep these points in mind when you compare the system tables with other sources:

  • Member cluster alias. Data mappings, session pins, and moves name a member cluster by its alias. The alias exists only at the routing layer. The Amazon RDS console, the AWS CLI, and Amazon CloudWatch show the DB cluster identifier. Read the alias from member_cluster_mappings, and don't derive it from a DB cluster identifier.

  • Session ID. The routing layer gives each client connection a global connection ID: a 32-bit positive integer that is unique across the group and names the connection. You see it in the process list, as ID in router_processlist on Aurora MySQL. On an Aurora MySQL member cluster, the connection attributes _rds_router_connection_id and _rds_connection_source carry the global connection ID and the source of the connection. To follow a session to its member cluster, see Tracing a session or statement across the group.

  • Names in catalogs. A catalog read through the routing endpoint returns the names that the data mappings define. A pinned session or a direct connection returns cluster names. Route data statements through the routing endpoint, and run schema changes and catalog introspection through a pinned session or a direct connection. For more information, see Statement compatibility.

  • Declarations and data. The system tables hold the placement that you declare. The routing layer doesn't compare these declarations with the objects or rows on the member clusters, and no statement reports a difference between them. Keeping the member clusters in step with your declarations stays under your control.

The DB cluster identifier appears in the system tables under the column name db_cluster_identifier, which is its public name.

Related topics

Some routing layer state isn't in a system table. The following topics describe it, and how to follow a session to its member clusters: