Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21790

secondary index corruption after 10.3.21 upgrade from 5.5

Details

    Description

      Hi,

      I have been working on upgrading all of our MariaDB 5.5.63 servers since EOL is approaching.

      So far I have upgraded 10 servers, and still have several more servers to go including our galera cluster. So far 3 of the servers after they were upgraded started with random corrupt secondary index on certain table not all just a few. I don't know or understand why it happening on some of the 10.3.21 servers that were upgrade but not all of them. I followed the same directions that is on the MariaDB site for each major version and made sure to run SET GLOBAL innodb_fast_shutdown=0 as per the documentation before each upgrade from 5.5. - > 10.0, 10.0 - > 10.1, 10.1 -> 10.2, 10.2 -> 10.3.21

      After each upgrade I run mysql_upgrade and everything is clean. I started to see this error in the logs very soon after the upgrade. I know the fix is to recreate the indexes, but some of our tables are extremely large (for ex. 405 million rows ) and takes a very long time to create a new index.

      Here is a the error that I see many times in the logs:

      2020-02-20 14:28:09 3 [ERROR] InnoDB: tried to purge non-delete-marked record in index `index_name` of table `schemaname`.`tablename`: tuple: TUPLE (info_bits=0, 4 fields):

      {NULL,[4] YCn(0xAD59436E),[4] (0x7FFFFFFF),[4] @(0x800CD040)}, record: COMPACT RECORD(info_bits=0, 4 fields): {NULL,[4] YCn(0xAD59436E),[4] (0x7FFFFFFF),[4] @(0x800CD040)}

      2020-02-21 12:01:41 2 [ERROR] InnoDB: Unable to find a record to delete-mark
      InnoDB: tuple DATA TUPLE: 2 fields;
      0: len 4; hex 8108d277; asc w;;
      1: len 4; hex 85cd439c; asc C ;;

      InnoDB: record PHYSICAL RECORD: n_fields 2; compact format; info bits 0
      0: len 4; hex 8108d273; asc s;;
      1: len 4; hex 85c057ef; asc W ;;
      2020-02-21 12:01:41 2 [ERROR] InnoDB: page [page id: space=242, page number=96050] (941 records, index id 594).
      2020-02-21 12:01:41 2 [ERROR] InnoDB: Submit a detailed bug report to https://jira.mariadb.org/

      Is there anything I can do to prevent this from happening? Is this a bug? I am not concerned with small tables, but to get corrupted secondary indexes on large tables would cause a major issue in production, once we upgrade our Galera Cluster from MariaDB 5.5 to 10.3

      Thanks

      Attachments

        Issue Links

          Activity

            kmanero Kevin Manero added a comment - - edited

            I don't know if it is related to this. MDEV-21726

            Based on the comments there I applied these settings

            SET GLOBAL innodb_change_buffering=inserts;
             
            SET GLOBAL innodb_adaptive_hash_index=OFF;
            

            But now still get a similar ERROR , this time the record was not found , I am not sure if related to this or not

            2020-02-25 14:57:33 12 [ERROR] InnoDB: Record in index `index_name` of table `schema_name`.`table_name` was not found on update: TUPLE (info_bits=0, 4 fields):

            {NULL,[4] 6j (0x80366A1A),[4] (0x7FFFFFFF),[4] 0(0x80087F30)}

            at: COMPACT RECORD(info_bits=0, 4 fields):

            {NULL,[4] 6j (0x80366A1A),[4] (0x7FFFFFFF),[4] j (0x80086A82)}

            and when I ran a mysqlcheck on the table it was flagged as corrupt

            kmanero Kevin Manero added a comment - - edited I don't know if it is related to this. MDEV-21726 Based on the comments there I applied these settings SET GLOBAL innodb_change_buffering=inserts;   SET GLOBAL innodb_adaptive_hash_index=OFF; But now still get a similar ERROR , this time the record was not found , I am not sure if related to this or not 2020-02-25 14:57:33 12 [ERROR] InnoDB: Record in index `index_name` of table `schema_name`.`table_name` was not found on update: TUPLE (info_bits=0, 4 fields): {NULL,[4] 6j (0x80366A1A),[4] (0x7FFFFFFF),[4] 0(0x80087F30)} at: COMPACT RECORD(info_bits=0, 4 fields): {NULL,[4] 6j (0x80366A1A),[4] (0x7FFFFFFF),[4] j (0x80086A82)} and when I ran a mysqlcheck on the table it was flagged as corrupt
            kmanero Kevin Manero added a comment - - edited

            One note I forgot to add our architecture is a 5 node Galera cluster that we use for our most of our writes and some reads, we then have 10 slaves that replicate off of our galera nodes used for read-only. The slave servers that I upgrade to 10.3.21 that we are seeing the errors (we have not upgraded galera cluster yet so not sure if we will get it on galera as well). We are upgrading the slaves first , so will be replicating from 5.5 -> 10.3, once all the slaves are fully upgraded we then plan to upgrade the galera cluster from 5.5 to 10.3

            The version of our galera cluster nodes which is also the master are:

            MariaDB-devel-5.5.63-1.el6.x86_64
            MariaDB-common-5.5.63-1.el6.x86_64
            MariaDB-Galera-server-5.5.63-1.el6.x86_64
            MariaDB-compat-5.5.63-1.el6.x86_64
            MariaDB-client-5.5.63-1.el6.x86_64

            The version for the slaves is all 10.3.21, we also have tried 10.3.22 but still have the same issue.

            Here are some of the most common settings in the 10.3.21 slave in my.cnf just to give a background that we have either had to add in the upgrade or I think might be important to know:

            binlog_format=ROW
            default_storage_engine=innodb
            innodb_change_buffering=inserts
            innodb_adaptive_hash_index=OFF
            innodb_strict_mode=OFF
            optimizer_switch='extended_keys=off'
            in_predicate_conversion_threshold = 0
            sql_mode=""

            Also just to add I ran mysqlcheck -C on our entire database while it was 5.5 on the slave server to confirm there was no corruption before the upgrade from 5.5 to 10.3. Once I upgraded these servers to 10.3, i then ran mysqlcheck -C again with no replication started yet showed no corruption, but once I start replication (start slave) and let it run from anywhere from a few hours to a week, the errors will then show up randomly just from the replication queries, without any other traffic hitting the server.

            kmanero Kevin Manero added a comment - - edited One note I forgot to add our architecture is a 5 node Galera cluster that we use for our most of our writes and some reads, we then have 10 slaves that replicate off of our galera nodes used for read-only. The slave servers that I upgrade to 10.3.21 that we are seeing the errors (we have not upgraded galera cluster yet so not sure if we will get it on galera as well). We are upgrading the slaves first , so will be replicating from 5.5 -> 10.3, once all the slaves are fully upgraded we then plan to upgrade the galera cluster from 5.5 to 10.3 The version of our galera cluster nodes which is also the master are: MariaDB-devel-5.5.63-1.el6.x86_64 MariaDB-common-5.5.63-1.el6.x86_64 MariaDB-Galera-server-5.5.63-1.el6.x86_64 MariaDB-compat-5.5.63-1.el6.x86_64 MariaDB-client-5.5.63-1.el6.x86_64 The version for the slaves is all 10.3.21, we also have tried 10.3.22 but still have the same issue. Here are some of the most common settings in the 10.3.21 slave in my.cnf just to give a background that we have either had to add in the upgrade or I think might be important to know: binlog_format=ROW default_storage_engine=innodb innodb_change_buffering=inserts innodb_adaptive_hash_index=OFF innodb_strict_mode=OFF optimizer_switch='extended_keys=off' in_predicate_conversion_threshold = 0 sql_mode="" Also just to add I ran mysqlcheck -C on our entire database while it was 5.5 on the slave server to confirm there was no corruption before the upgrade from 5.5 to 10.3. Once I upgraded these servers to 10.3, i then ran mysqlcheck -C again with no replication started yet showed no corruption, but once I start replication (start slave) and let it run from anywhere from a few hours to a week, the errors will then show up randomly just from the replication queries, without any other traffic hitting the server.
            kmanero Kevin Manero added a comment -

            Wanted to give one more update, as a test, we launched a test cluster with just one galera node with 5.5 and a slave 5.5, then upgraded the slave first, did not start replication yet, then upgraded the galera node test cluster to 10.3. So now we had replication from 10.3 - > 10.3 , and once we started replication and let it catch up, we started to see the same errors and certain tables then became corrupt, we wanted to rule out that maybe it was a version issue from replicating from a very old version.

            kmanero Kevin Manero added a comment - Wanted to give one more update, as a test, we launched a test cluster with just one galera node with 5.5 and a slave 5.5, then upgraded the slave first, did not start replication yet, then upgraded the galera node test cluster to 10.3. So now we had replication from 10.3 - > 10.3 , and once we started replication and let it catch up, we started to see the same errors and certain tables then became corrupt, we wanted to rule out that maybe it was a version issue from replicating from a very old version.
            kmanero Kevin Manero added a comment -

            We changed the following settings and this seems to have fixed corruption issue, but we now we are taking performance hit in updates/inserts, the performance is worst then in 5.5:

            innodb_change_buffering=none
            innodb_adaptive_hash_index=OFF

            As soon as we change these values back to default the performance is back to normal. Any ideas? is this normal?

            kmanero Kevin Manero added a comment - We changed the following settings and this seems to have fixed corruption issue, but we now we are taking performance hit in updates/inserts, the performance is worst then in 5.5: innodb_change_buffering=none innodb_adaptive_hash_index=OFF As soon as we change these values back to default the performance is back to normal. Any ideas? is this normal?

            In our internal stress testing with Random Query Generator (RQG), we rarely encounter something in the MDEV-9663 family of bugs (indexes of a table being inconsistent with each other). Over time, and with some luck, we may come up with another simplified test case, such as the one that helped us fix the MySQL 5.5 bug MDEV-18272 that can introduce such corruption. Recently, we have started employing https://rr-project.org/ which allows us to deterministically replay failures. That is our main hope for eventually catching such bugs.

            The challenge is that we need the full history of the database server, from the creation of the table. If we lack that, we can only guess. Both the adaptive hash index and the change buffer are very nondeterministic in nature, which is adding some challenges. For the adaptive hash index, there are some open bugs which we have not tackled yet (noted in MDEV-20487). In 10.5, the change buffer is a little more deterministic thanks to MDEV-19514.

            marko Marko Mäkelä added a comment - In our internal stress testing with Random Query Generator (RQG), we rarely encounter something in the MDEV-9663 family of bugs (indexes of a table being inconsistent with each other). Over time, and with some luck, we may come up with another simplified test case, such as the one that helped us fix the MySQL 5.5 bug MDEV-18272 that can introduce such corruption. Recently, we have started employing https://rr-project.org/ which allows us to deterministically replay failures. That is our main hope for eventually catching such bugs. The challenge is that we need the full history of the database server, from the creation of the table. If we lack that, we can only guess. Both the adaptive hash index and the change buffer are very nondeterministic in nature, which is adding some challenges. For the adaptive hash index, there are some open bugs which we have not tackled yet (noted in MDEV-20487 ). In 10.5, the change buffer is a little more deterministic thanks to MDEV-19514 .

            I am wondering whether newer versions are just better at catching corruption. If the table was connected to a FOREIGN KEY constraint, MDEV-18272 could have explained the corruption. But I think that it is a rather unlikely explanation.

            The message that preceded the “tried to purge non-delete-marked record” (“entry not marked for deletion”) was introduced in MySQL 5.6.21 and MariaDB 10.0.15.

            In MySQL 5.5 and MariaDB 5.5, there still was only one purge thread. Starting with 5.6 and 10.0, multiple innodb_purge_threads could be set. The default was changed from 1 to 4 in MySQL 5.7.8 and MariaDB 10.2.2.

            Theoretically, it might be the case that multiple purge threads are causing this corruption. I have not carefully reviewed the code. But, we also have been unable to reproduce this internally. Maybe we should try more with non-debug executables?

            marko Marko Mäkelä added a comment - I am wondering whether newer versions are just better at catching corruption. If the table was connected to a FOREIGN KEY constraint, MDEV-18272 could have explained the corruption. But I think that it is a rather unlikely explanation. The message that preceded the “tried to purge non-delete-marked record” (“entry not marked for deletion”) was introduced in MySQL 5.6.21 and MariaDB 10.0.15 . In MySQL 5.5 and MariaDB 5.5, there still was only one purge thread. Starting with 5.6 and 10.0, multiple innodb_purge_threads could be set. The default was changed from 1 to 4 in MySQL 5.7.8 and MariaDB 10.2.2. Theoretically, it might be the case that multiple purge threads are causing this corruption. I have not carefully reviewed the code. But, we also have been unable to reproduce this internally. Maybe we should try more with non-debug executables?

            Some progress on diagnosing this form of corruption has been made in MDEV-22373.

            marko Marko Mäkelä added a comment - Some progress on diagnosing this form of corruption has been made in MDEV-22373 .

            People

              marko Marko Mäkelä
              kmanero Kevin Manero
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.