sofastack/sofa-registry

Use `create_Table.sql` failed to build the database

ashlee618 opened this issue · 1 comments

Describe the bug

Use create_Table.sql failed to build the database,

mysql> source F:/create_table.sql
Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.04 sec)

ERROR 1068 (42000): Multiple primary key defined
mysql>

The specific reason should be that the creation of primary key is repeated in these two places, multi_cluster_sync_info table.

image

When I delete one of them, I find that the error will still be reported. It is the error of the index that is too long,still the multi_cluster_sync_info table.

  • mysql5.5:Under the innodb engine, we can start innodb_large_Prefix parameter to extend the length of a single index to 3072 bytes (but the length of a joint index is still limited to 3072 bytes).

  • mysql8.0:the innodb_large_prefix parameter is deprecated,The default is 3072 bytes.

mysql> source F:/create_table.sql
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes
mysql>

So should we consider prefix index or reconsider the creation of index

Environment

  • SOFARegistry version: master
  • Mysql version: 8

Thanks for raising this issue:

  • repeated primary key in multi_cluster_sync_info can not create table while using mysql,this is a difference between mysql and h2db, we will fix this bug later;
  • after fix repeated primary key, the error whie creating table in mysql is timestamp must set default value, this is another difference between mysql and h2db;

after fix two problem, we test it in mysql5.7 and mysql:latest, it work well;

image

image

fix pr: #305

Please try it again, thanks.