(PARTITION p20170913 VALUES LESS THAN ('2017-09-14') ENGINE = InnoDB,
PARTITION p20170914 VALUES LESS THAN ('2017-09-15') ENGINE = InnoDB,
PARTITION p20170915 VALUES LESS THAN ('2017-09-16') ENGINE = InnoDB,
PARTITION p20170916 VALUES LESS THAN ('2017-09-17') ENGINE = InnoDB,
PARTITION p20170917 VALUES LESS THAN ('2017-09-18') ENGINE = InnoDB,
PARTITION p99991231 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */;
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
replace into t(d,a,b) select '2017-09-15',rand()*10000,rand()*10 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14;
We can see that the table has over 16k rows:
MariaDB [db1]> select count(*) from t where d ='2017-09-15';
+----------+
| count(*) |
+----------+
| 16386 |
+----------+
1 row in set (0.00 sec)
But things break if we alter the table:
ALTER TABLE t CHANGE b c smallint(5) unsigned , ADD KEY idx_d_a (d, a);
analyze table t;
Now that the table has been altered, let's compare the output of these two queries:
select count(*) from t where d ='2017-09-15';
select count(*) from t force index(primary) where d ='2017-09-15';
Here's the actual output:
MariaDB [db1]> select count(*) from t where d ='2017-09-15';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
MariaDB [db1]> select count(*) from t force index(primary) where d ='2017-09-15';
+----------+
| count(*) |
+----------+
| 16386 |
+----------+
1 row in set (0.00 sec)
We can see that output for the first query is incorrect.
Rebuilding the table seems to fix it:
MariaDB [db1]> alter table t engine = InnoDB;
Query OK, 0 rows affected (0.24 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [db1]> select count(*) from t where d ='2017-09-15';
+----------+
| count(*) |
+----------+
| 16386 |
+----------+
1 row in set (0.00 sec)
Attachments
Issue Links
relates to
MDEV-7367Updating a virtual column corrupts table which crashes server
The code changes look OK to me.
Please address my most recent review comments and let me know when buildbot has finished running the revised tests. I would like to have one last look before the push.
Marko Mäkelä
added a comment - The code changes look OK to me.
Please address my most recent review comments and let me know when buildbot has finished running the revised tests. I would like to have one last look before the push.
commit fc9ff69578fa8c3d818d6eaaa171b4be49d70814
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date: Tue Oct 10 10:19:10 2017 +0300
MDEV-13838: Wrong result after altering a partitioned table
Reverted incorrect changes done on MDEV-7367 and MDEV-9469. Fixes properly
also related bugs:
MDEV-13668: InnoDB unnecessarily rebuilds table when renaming a column and adding index MDEV-9469: 'Incorrect key file' on ALTER TABLE MDEV-9548: Alter table (renaming and adding index) fails with "Incorrect key file for table" MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash MDEV-13640: ALTER TABLE CHANGE and ADD INDEX on auto_increment column fails with "Incorrect key file for table..."
Root cause for all these bugs is the fact that MariaDB .frm file
can contain virtual columns but InnoDB dictionary does not and
previous fixes were incorrect or unnecessarily forced table
rebuilt. In index creation key_part->fieldnr can be bigger than
number of columns in InnoDB data dictionary. We need to skip not
stored fields when calculating correct column number for InnoDB
data dictionary.
dict_table_get_col_name_for_mysql
Remove
innobase_match_index_columns
Revert incorrect change done on MDEV-7367
innobase_need_rebuild
Remove unnecessary rebuild force when column is renamed.
innobase_create_index_field_def
Calculate InnoDB column number correctly and remove
unnecessary column name set.
row_merge_create_index
Remove unneeded col_names parameter and resolution.
Effected tests:
innodb-alter-table : Add test case for MDEV-13668
innodb-alter : Remove MDEV-13668, MDEV-9469 FIXMEs
and restore original tests
innodb-wl5980-alter : Remove MDEV-13668, MDEV-9469 FIXMEs
and restore original tests
Jan Lindström (Inactive)
added a comment - commit fc9ff69578fa8c3d818d6eaaa171b4be49d70814
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date: Tue Oct 10 10:19:10 2017 +0300
MDEV-13838 : Wrong result after altering a partitioned table
Reverted incorrect changes done on MDEV-7367 and MDEV-9469 . Fixes properly
also related bugs:
MDEV-13668 : InnoDB unnecessarily rebuilds table when renaming a column and adding index
MDEV-9469 : 'Incorrect key file' on ALTER TABLE
MDEV-9548 : Alter table (renaming and adding index) fails with "Incorrect key file for table"
MDEV-10535 : ALTER TABLE causes standalone/wsrep cluster crash
MDEV-13640 : ALTER TABLE CHANGE and ADD INDEX on auto_increment column fails with "Incorrect key file for table..."
Root cause for all these bugs is the fact that MariaDB .frm file
can contain virtual columns but InnoDB dictionary does not and
previous fixes were incorrect or unnecessarily forced table
rebuilt. In index creation key_part->fieldnr can be bigger than
number of columns in InnoDB data dictionary. We need to skip not
stored fields when calculating correct column number for InnoDB
data dictionary.
dict_table_get_col_name_for_mysql
Remove
innobase_match_index_columns
Revert incorrect change done on MDEV-7367
innobase_need_rebuild
Remove unnecessary rebuild force when column is renamed.
innobase_create_index_field_def
Calculate InnoDB column number correctly and remove
unnecessary column name set.
innobase_create_index_def, innobase_create_key_defs
Remove unneeded fields parameter. Revert unneeded memset.
prepare_inplace_alter_table_dict
Remove unneeded col_names parameter
index_field_t
Remove unneeded col_name member.
row_merge_create_index
Remove unneeded col_names parameter and resolution.
Effected tests:
innodb-alter-table : Add test case for MDEV-13668
innodb-alter : Remove MDEV-13668 , MDEV-9469 FIXMEs
and restore original tests
innodb-wl5980-alter : Remove MDEV-13668 , MDEV-9469 FIXMEs
and restore original tests
Marko Mäkelä
added a comment - A tentative merge to 10.2 revealed that an upstream bug fix was inadvertently reverted in a merge of MySQL 5.7.9 into MariaDB Server 10.2.2 . I pushed a fix to bb-10.2-marko.
People
Jan Lindström (Inactive)
Geoff Montee (Inactive)
Votes:
2Vote for this issue
Watchers:
7Start 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.
{"report":{"fcp":1279.2999999523163,"ttfb":418,"pageVisibility":"visible","entityId":63211,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"249198c6-ffe4-4a21-91e9-abe2ceddfa0e","navigationType":0,"readyForUser":1372,"redirectCount":0,"resourceLoadedEnd":1291.8999999761581,"resourceLoadedStart":423.5,"resourceTiming":[{"duration":322,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":423.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":423.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":745.5,"responseStart":0,"secureConnectionStart":0},{"duration":322.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":423.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":423.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":745.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":331,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":424,"connectEnd":424,"connectStart":424,"domainLookupEnd":424,"domainLookupStart":424,"fetchStart":424,"redirectEnd":0,"redirectStart":0,"requestStart":424,"responseEnd":755,"responseStart":755,"secureConnectionStart":424},{"duration":385.5999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":424.19999998807907,"connectEnd":424.19999998807907,"connectStart":424.19999998807907,"domainLookupEnd":424.19999998807907,"domainLookupStart":424.19999998807907,"fetchStart":424.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":424.19999998807907,"responseEnd":809.7999999523163,"responseStart":809.7999999523163,"secureConnectionStart":424.19999998807907},{"duration":389.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":424.39999997615814,"connectEnd":424.39999997615814,"connectStart":424.39999997615814,"domainLookupEnd":424.39999997615814,"domainLookupStart":424.39999997615814,"fetchStart":424.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":424.39999997615814,"responseEnd":813.7999999523163,"responseStart":813.7999999523163,"secureConnectionStart":424.39999997615814},{"duration":389.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":424.5,"connectEnd":424.5,"connectStart":424.5,"domainLookupEnd":424.5,"domainLookupStart":424.5,"fetchStart":424.5,"redirectEnd":0,"redirectStart":0,"requestStart":424.5,"responseEnd":814.2999999523163,"responseStart":814.2999999523163,"secureConnectionStart":424.5},{"duration":390,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":424.69999998807907,"connectEnd":424.69999998807907,"connectStart":424.69999998807907,"domainLookupEnd":424.69999998807907,"domainLookupStart":424.69999998807907,"fetchStart":424.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":424.69999998807907,"responseEnd":814.6999999880791,"responseStart":814.6999999880791,"secureConnectionStart":424.69999998807907},{"duration":474.30000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":424.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":424.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":899.1999999880791,"responseStart":0,"secureConnectionStart":0},{"duration":390.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":425.0999999642372,"connectEnd":425.0999999642372,"connectStart":425.0999999642372,"domainLookupEnd":425.0999999642372,"domainLookupStart":425.0999999642372,"fetchStart":425.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":425.0999999642372,"responseEnd":815.1999999880791,"responseStart":815.1999999880791,"secureConnectionStart":425.0999999642372},{"duration":474.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":425.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":425.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":899.3999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":390.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":425.39999997615814,"connectEnd":425.39999997615814,"connectStart":425.39999997615814,"domainLookupEnd":425.39999997615814,"domainLookupStart":425.39999997615814,"fetchStart":425.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":425.39999997615814,"responseEnd":815.8999999761581,"responseStart":815.8999999761581,"secureConnectionStart":425.39999997615814},{"duration":671.0999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":431.19999998807907,"connectEnd":431.19999998807907,"connectStart":431.19999998807907,"domainLookupEnd":431.19999998807907,"domainLookupStart":431.19999998807907,"fetchStart":431.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":431.19999998807907,"responseEnd":1102.2999999523163,"responseStart":1102.2999999523163,"secureConnectionStart":431.19999998807907},{"duration":854.4000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":431.2999999523163,"connectEnd":431.2999999523163,"connectStart":431.2999999523163,"domainLookupEnd":431.2999999523163,"domainLookupStart":431.2999999523163,"fetchStart":431.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":431.2999999523163,"responseEnd":1285.699999988079,"responseStart":1285.699999988079,"secureConnectionStart":431.2999999523163},{"duration":191.19999998807907,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":911.8999999761581,"connectEnd":911.8999999761581,"connectStart":911.8999999761581,"domainLookupEnd":911.8999999761581,"domainLookupStart":911.8999999761581,"fetchStart":911.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":911.8999999761581,"responseEnd":1103.0999999642372,"responseStart":1103.0999999642372,"secureConnectionStart":911.8999999761581},{"duration":119.69999998807907,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1172.199999988079,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1172.199999988079,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1291.8999999761581,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":231,"responseStart":418,"responseEnd":426,"domLoading":422,"domInteractive":1437,"domContentLoadedEventStart":1437,"domContentLoadedEventEnd":1485,"domComplete":1794,"loadEventStart":1794,"loadEventEnd":1795,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1420.5999999642372},{"name":"bigPipe.sidebar-id.end","time":1421.3999999761581},{"name":"bigPipe.activity-panel-pipe-id.start","time":1421.5999999642372},{"name":"bigPipe.activity-panel-pipe-id.end","time":1423.2999999523163},{"name":"activityTabFullyLoaded","time":1514.199999988079}],"measures":[],"correlationId":"163e126f59c70e","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":122,"dbReadsTimeInMs":19,"dbConnsTimeInMs":29,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The code changes look OK to me.
Please address my most recent review comments and let me know when buildbot has finished running the revised tests. I would like to have one last look before the push.