sofastack / sofa-registry

SOFARegistry is a production-level, low-latency, high-availability service registry powered by Ant Financial.
https://www.sofastack.tech/sofa-registry/docs/Home
Apache License 2.0
653 stars 247 forks source link

Use `create_Table.sql` failed to build the database #303

Closed ashlee618 closed 1 year ago

ashlee618 commented 1 year ago

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

nocvalight commented 1 year ago

Thanks for raising this issue:

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.