Bug #85396 tablespaces should be supported by other engines then innodb
Submitted: 10 Mar 2017 7:34 Modified: 20 Mar 2017 15:10
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Dictionary Severity:S2 (Serious)
Version:8.0.1 OS:Any
Assigned to: CPU Architecture:Any

[10 Mar 2017 7:34] Magnus Blåudd
Description:
Trying to create a tablespace in another engine than Innodb on a debug compiled MySQL Server will cause a DBUG_ASSERT() to fire in store(handlerton *hton, const MYSQL_LEX_CSTRING &sdi, const Tablespace *tablespace) of the file sdi_tablespace.cc. This seems to be caused by the assumption that only Inodb can have tablespaces. If commenting out the first DBUG_ASSERT, you will hit a second DBUG_ASSERT requiring that the hton->sdi_set callback is installed.

diff --git a/sql/dd/impl/sdi_tablespace.cc b/sql/dd/impl/sdi_tablespace.cc
index d731633..28f7418 100644
--- a/sql/dd/impl/sdi_tablespace.cc
+++ b/sql/dd/impl/sdi_tablespace.cc
@@ -216,7 +216,13 @@ bool store(handlerton *hton, const MYSQL_LEX_CSTRING &sdi,
            const Tablespace *tablespace)
 {
   DBUG_ASSERT(hton->db_type == DB_TYPE_INNODB);
+  //                           ^^^^^^^^^^^^^^
+  // Also other engines support tablespaces
   DBUG_ASSERT(hton->sdi_set != nullptr);
+  //                           ^^^^^^^
+  // If it is a requirement to have the sdi_set callback installed
+  // please check that requirement after handlerton->init(); instead of
+  // at random places in the code
   if (!tablespace->se_private_data().exists("id"))
   {

How to repeat:

CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 1M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;

CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 1M
ENGINE NDB;

Suggested fix:
Remove the DBUG_ASSERT checking that hton is Innodb.

Remove the DBUG_ASSERT which check that hton->sdi_set callback function is set. If it need to be set, such a check should be done after the handlerton::init() function has been called and produce a proper error message.
[20 Mar 2017 15:10] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.2 release, and here's the changelog entry:

In debug builds, a CREATE TABLESPACE operation raised an invalid
assertion when using the NDB storage engine. A validation function that
checked for zero-length data files did not apply to NDB tablepaces and was
removed.