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

Persistent AUTO_INCREMENT for InnoDB

Details

    • 10.2.4-1

    Description

      The current auto_increment behavior in the InnoDB engine is sub-optimal. As it currently functions, the auto_increment value is stored until the server shuts down or resets, and then is rebuilt based on values in the table when it starts up again. Furthermore, in 5.6 this ought to become even worse, because tables can be evicted from the InnoDB data dictionary cache. We may get a too low auto-increment value even without shutdown/restart. When a table is evicted, InnoDB will forget the current auto-increment value, and it will do SELECT MAX(auto_inc_column) next time when the table is accessed.

      Attachments

        Issue Links

          Activity

            I pushed a fix to the conflict with MDEV-5800/WL#8114/WL#8149 (virtual columns).
            The new function innodb_col_no() will determine the dict_table_t::cols[] offset of a Field.

            marko Marko Mäkelä added a comment - I pushed a fix to the conflict with MDEV-5800 /WL#8114/WL#8149 (virtual columns). The new function innodb_col_no() will determine the dict_table_t::cols[] offset of a Field.

            This looks good now.

            jplindst Jan Lindström (Inactive) added a comment - This looks good now.

            Thanks! I just pushed to bb-10.2-mdev-6076 rebased to latest 10.2, so that we avoid one test failure due to a bug in slow shutdown that was introduced in MDEV-5800 and fixed later.

            The only code change since the review is the correction of a debug assertion that I had added late yesterday:

            diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
            index 39eadda318f..798aeeed74f 100644
            --- a/storage/innobase/page/page0zip.cc
            +++ b/storage/innobase/page/page0zip.cc
            @@ -4851,8 +4851,8 @@ page_zip_copy_recs(
             	} else {
             		/* The PAGE_MAX_TRX_ID must be nonzero on leaf pages
             		of secondary indexes, and 0 on others. */
            -		ut_a(dict_table_is_temporary(index->table)
            -		     || page_is_leaf(src) == !page_get_max_trx_id(src));
            +		ut_ad(dict_table_is_temporary(index->table)
            +		      || !page_is_leaf(src) == !page_get_max_trx_id(src));
             	}
             
             	/* Copy all fields of src_zip to page_zip, except the pointer
            

            I also removed many restarts from the test innodb.autoinc_persist, testing more things across each restart.

            marko Marko Mäkelä added a comment - Thanks! I just pushed to bb-10.2-mdev-6076 rebased to latest 10.2, so that we avoid one test failure due to a bug in slow shutdown that was introduced in MDEV-5800 and fixed later. The only code change since the review is the correction of a debug assertion that I had added late yesterday: diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 39eadda318f..798aeeed74f 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4851,8 +4851,8 @@ page_zip_copy_recs( } else { /* The PAGE_MAX_TRX_ID must be nonzero on leaf pages of secondary indexes, and 0 on others. */ - ut_a(dict_table_is_temporary(index->table) - || page_is_leaf(src) == !page_get_max_trx_id(src)); + ut_ad(dict_table_is_temporary(index->table) + || !page_is_leaf(src) == !page_get_max_trx_id(src)); } /* Copy all fields of src_zip to page_zip, except the pointer I also removed many restarts from the test innodb.autoinc_persist, testing more things across each restart.

            Now that 10.2.3 was released and 10.1 was merged to 10.2, I finally pushed this.

            marko Marko Mäkelä added a comment - Now that 10.2.3 was released and 10.1 was merged to 10.2, I finally pushed this.

            MDEV-12123 fixed a related bug. When using IMPORT TABLESPACE with data files on which IMPORT TABLESPACE has been used before the MDEV-12123 fix, the AUTO_INCREMENT value will be restored to a bogus value (something that was a transaction ID in the previous IMPORT).

            marko Marko Mäkelä added a comment - MDEV-12123 fixed a related bug. When using IMPORT TABLESPACE with data files on which IMPORT TABLESPACE has been used before the MDEV-12123 fix, the AUTO_INCREMENT value will be restored to a bogus value (something that was a transaction ID in the previous IMPORT).

            People

              marko Marko Mäkelä
              jplindst Jan Lindström (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              12 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.