What is truth?

Today I found myself questioning reality itself.

This database query returned 7 rows:

MariaDB [db]> select * from wp_icl_strings where context = 'theme' order by id desc;

This database query returned 1511 rows:

MariaDB [db]> select * from wp_icl_strings where context = 'theme';

As anyone who knows SQL should know, these 2 queries should definitely be returning the same number of rows.

I tried repeating the queries, just to make sure. I got the same results.

As this bizarre result came at a time that I was already fighting a maddening bug in WPML string translations, it felt like I had now entered a reality where 1 + 1 had suddenly started to equal 3.

Fortunately for my sanity, the database server also agreed that this broke reality:

MariaDB [db]> check table wp_icl_strings;
ERROR 2013 (HY000): Lost connection to MySQL server during query
...
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR: Can't connect to the server

Yes, trying to check that table for consistency successfully crashed MariaDB.

Just for fun, I tried it again, and found that yep, I can crash this database on demand now.

The logs were a bit more revealing:

Jul 29 14:47:56 dbserver-3 mysqld[1496634]: 2021-07-29 14:47:56 62 [ERROR] InnoDB: Corruption of an index tree: table `db`.`wp_icl_strings` index `language_context`, father ptr page no 679, child page no 303
Jul 29 14:47:56 dbserver-3 mysqld[1496634]: PHYSICAL RECORD: n_fields 3; compact format; info bits 0
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  0: len 2; hex 656e; asc en;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  1: len 3; hex 616366; asc acf;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  2: len 8; hex 000000000000443b; asc       D;;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]: 2021-07-29 14:47:56 62 [Note] InnoDB: n_owned: 0; heap_no: 2; next rec: 147
Jul 29 14:47:56 dbserver-3 mysqld[1496634]: PHYSICAL RECORD: n_fields 4; compact format; info bits 0
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  0: len 2; hex 656e; asc en;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  1: len 7; hex 57696467657473; asc Widgets;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  2: len 8; hex 00000000060f0657; asc        W;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]:  3: len 4; hex 000002a7; asc     ;;
Jul 29 14:47:56 dbserver-3 mysqld[1496634]: 2021-07-29 14:47:56 62 [Note] InnoDB: n_owned: 0; heap_no: 32; next rec: 151
Jul 29 14:47:56 dbserver-3 mysqld[1496634]: 2021-07-29 14:47:56 62 [ERROR] [FATAL] InnoDB: You should dump + drop + reimport the table to fix the corruption. If the crash happens at database startup. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery. Then dump + drop + reimport.

Sure enough, the advice there to dump + drop + reimport the table to fix the corruption was exactly what needed to be done. A simple fix that took no time at all.

If only the rest of reality were so easy to fix.

Join the Conversation

  1. In FORTRAN, you could modify “constants”, and you could get weird results like this.

Comment

Your email address will not be published. Required fields are marked *