Troubleshooting

SQL problems

Common surprises when running SQL on Raft DB (unsupported statements, comparisons, names, uniqueness after a crash, stale definitions, transactions) and how to deal with them.

The numbers in brackets are MySQL error numbers; the full table is in Error numbers.

"This version of the Raft DB MySQL front-end doesn't yet support ..." (1235)#

The statement is valid MySQL or MariaDB that Raft DB has not built. It is refused by name instead of being ignored or misread. The text names the feature (partitioning, full-text and spatial indexes in CREATE TABLE, SET PERSIST, RENAME TABLE, LOAD DATA INFILE, roles and proxy grants, EXPLAIN ANALYZE, cursors (COM_STMT_FETCH), and others). See What is not there yet. Rewrite the statement (for a partitioned table, drop the PARTITION BY clause), or leave the feature out. A tool that issues such a statement on connect needs a setting that switches it off.

A statement works on MySQL and gives a different result here#

  • Comparison and ORDER BY of text ignore case, as MySQL's default collation does, but do not ignore accents: é is not e. A binary or case-sensitive COLLATE is refused (1235).
  • ONLY_FULL_GROUP_BY and strict mode follow the dialect's default sql_mode (MySQL: both; MariaDB: strict only). SET sql_mode = '' switches them off for the session (System variables).
  • Cardinality in SHOW INDEX is 0 (no statistics). The optimiser hints that depend on it have no effect.
  • SELECT ... FOR UPDATE locks nothing; LOCK TABLES locks nothing.
  • @@version is 8.0.36-Raft DB or 11.4.13-MariaDB-Raft DB; software that branches on versions sees MySQL 8.0 or MariaDB 11.4 features. The mysql, performance_schema and sys schemas do not exist as databases.
  • SHOW DATABASES lists only the databases made through this front-end of this dialect.
  • Server time zone is UTC (system_time_zone).
  • lower_case_table_names is reported as 0; D86 lists it as an open item (a Windows MySQL reports 1), so do not rely on the case of table names being treated as on a MySQL server.
  • Anything on the list of differences that cannot be made identical (D86): the server's identity, system schemas, the account names, MySQL's estimated index cardinality.

Errors about tables and names#

SymptomCauseFix
The table 'db.t' was not found (1146) for a table that was thereIt was dropped, renamed or never created in this front-end; or its definition is missingSHOW TABLES; check the database in use and the spelling.
The table's storage is missing (1146)The front-end has a definition but Raft DB has no table for it (data directory restored without it, or dropped through the native API)Restore the table's directory or drop the definition by dropping the table.
the definition of table 't' is damaged (1105)The stored definition does not parseRestore from a copy; send a bug report.
Incorrect table name 'x' (1103)A name starting __rdb_, __tmp or __u_ (the front-end's own), or one MySQL refuses (ending in a space, ., /, \, control characters, over 64 characters)Rename.
Unknown database (1049) after CREATE DATABASE through the native APIThe database is not this front-end'sCreate databases through SQL.

Uniqueness#

  • The value 'x' is already present for key ... (1062) is the primary key or a unique index working. Text is compared without case: 'a@x.com' and 'A@X.COM' collide.
  • A value cannot be inserted although no row has it (after a crash of the front-end in the middle of an insert): the claim of the unique value is kept for 30 seconds after the crash and then taken over. Wait and retry.
  • could not claim a unique value (1105): a race for a unique value that could not be settled; retry.
  • AUTO_INCREMENT has gaps after a rollback or failed insert, as in MySQL, and may skip values after a restart or when several front-ends share a server (a few retries, never a duplicate).

Transactions#

  • ROLLBACK works, but nothing is isolated: other sessions see uncommitted rows (1) and two sessions can overwrite each other (2). See the transactions tutorial.
  • A statement that fails inside a transaction is undone alone; the transaction goes on.
  • A DDL statement (CREATE, DROP, ALTER, TRUNCATE, GRANT, CREATE USER) commits the open transaction first.
  • A crash of the front-end in the middle of a transaction leaves what was written.

Data that does not fit#

Strict mode refuses, with MySQL's numbers: 1264 (out of range), 1265 (data truncated, a warning in non-strict mode), 1292 (incorrect date or number), 1366 (incorrect value, also text that is not UTF-8), 1406 (data too long), 1048 (NULL in a NOT NULL column), 1364 (no default). Look at the column's type with DESCRIBE; check @@sql_mode.

Stale views, routines, triggers or table definitions#

The front-end caches definitions for a short time (2 seconds for the definitions it reads again). A change made through another front-end on the same server is seen after that time; a change made through this one is seen at once. A GRANT through another front-end is seen at the next login.

Routines and triggers#

  • Routine r went past its recursion limit of 0, which comes from the max_sp_recursion_depth variable (1456): recursion is off by default; SET GLOBAL max_sp_recursion_depth = N.
  • A routine that runs more than 50 million statements and loop turns is stopped.
  • Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger (1442): a trigger may not change its own table.
  • A stored function that takes a column as an argument is refused as unsupported (1235).
  • BEFORE triggers of the update done by ON DUPLICATE KEY UPDATE, multi-table DELETE triggers and triggers on views are not done.

Prepared statements#

  • Prepared statement handler (N) is unknown to mysqld_stmt_execute (1243): the statement was closed or never prepared.
  • Can't create more than max_prepared_stmt_count statements (1461): a session holds 16,382 at most; close statements (COM_STMT_CLOSE).
  • A server-side cursor (COM_STMT_FETCH) is refused (1235): the driver should read the whole result (useCursorFetch=false).

JSON#

Invalid JSON text: "..." at position N in value for column 't.c' (3140) and ... in argument N to function f (3141) use MySQL's wording and position. Check the text with JSON_VALID.

See also#