[MDEV-23705] Assertion `table->data_dir_path || !space' failed in row_drop_table_for_mysql on TRUNCATE after DISCARD TABLESPACE Created: 2020-09-09 Updated: 2020-10-06 Resolved: 2020-09-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.2.35, 10.3.26, 10.4.16, 10.5.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Roel Van de Paar | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | debug, not-10.1 | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
Leads to:
Bug confirmed present in: Bug confirmed not present in: |
| Comments |
| Comment by Marko Mäkelä [ 2020-09-22 ] | ||||||||||||||||||||||||||||||||||||||||
|
This is a rather interesting bug. The DATA DIRECTORY flag will be wrongly set. And not only that, the table->data_dir_path will have been truncated to "./t":
I was suspecting heap-use-after-free, but WITH_ASAN will not flag anything before the assertion failure. We seem to get this truncated data_file_name = "./t" on the first invocation of ha_innobase::truncate(). | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-09-22 ] | ||||||||||||||||||||||||||||||||||||||||
|
After ALTER TABLE t DISCARD TABLESPACE, the tablespace will no longer exist, and dict_get_and_save_data_dir_path() would invoke dict_get_first_path() to read an entry from SYS_DATAFILES (which we plan to remove in I did not try to figure out why we truncate the name from "./test/t.ibd" to "./t". I think that this entire function dict_get_and_save_data_dir_path() is unnecessary (because unlike MySQL 5.7, we do not support CREATE TABLESPACE for InnoDB) and should be removed, possibly as part of | ||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2020-10-02 ] | ||||||||||||||||||||||||||||||||||||||||
|
Whilst this bug is resolved, I still had an older testcase which I wanted to add as it's quite different and sporadic (requires 10 to 500 executions to hit, and interestingly the drop/create does not seem to be required to hit the [now-fixed] bug):
It leads to the same assert on 10.4, does not produce on 10.5. I build 10.4.15 at revision bd64c2e8cc610dc774411c5f0a8ab163fc685934 today, and the bug does not reproduce there anymore with this testcase, or the one above (both tested on debug only), so I consider it solved. Interestingly, the testcase above (or quite close to it) led also to this assert (on the older revision) in the original run (and was reduced to the above). Perhaps the occurrence of this particular assert is even less pronounced, or requires the C-API for replay.
In any case, I will add this to the filters, and immediately remark this one as well as the original one. So, if any of this shows again, we'll pick up on it and know it's related. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2020-10-02 ] | ||||||||||||||||||||||||||||||||||||||||
|
Also interesting (and perhaps another bug) is that on the current version, the second truncate does not give the same warning as the first:
Not sure how that second truncate is able to complete "OK"? marko do you consider this another bug? | ||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2020-10-02 ] | ||||||||||||||||||||||||||||||||||||||||
|
Interestingly, the assertion `mysql_socket.fd != -1' is seen a lot of my runs on scanning the same. I wonder if it is a separate bug as well. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-10-02 ] | ||||||||||||||||||||||||||||||||||||||||
|
Roel, I believe the ALTER TABLE t DISCARD TABLESPACE is broken by design, basically corrupting the table by removing the data file while retaining the metadata. TRUNCATE TABLE will fix this corruption by creating an empty table. It will also issue a warning if the tablespace had been discarded. If you see assertions mysql_socket.fd != 1 failing, those should have nothing to do with InnoDB. In any case, that should be a separate bug. |