-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
type/enhancementAn improvement of existing functionalityAn improvement of existing functionality
Description
- Gitea version (or commit ref): gitea/gitea:1.15.0
- Git version: -
- Operating system: Linux (docker)
- Database (use
[x]
):- PostgreSQLMySQLMSSQLSQLiteTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)NoTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
- Log gist:
ORM engine initialization attempt #1/10 failed. Error: migrate: do migrate: Error 3750: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.
Description
Certain DB clusters (for example DigitalOcean's MySQL cluster) require the use of primary keys which until now was fine. It seems like this support was dropped since 1.15. This issue occurs at fresh installation of 1.15 and also when upgrading from 1.14
Metadata
Metadata
Assignees
Labels
type/enhancementAn improvement of existing functionalityAn improvement of existing functionality
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
lunny commentedon Aug 24, 2021
Could you give more logs, if you can enable log level to info, some information like
Migration[%d]: %s
should be above the error line.aqos156 commentedon Aug 24, 2021
@lunny log level is set to info in conf and this is the output of a fresh installation:
And this is log of migration from 1.14:
zeripath commentedon Aug 24, 2021
Looks like the problem is related to
ResourceIndex
in models/migrations/v182.go and models/index.golunny commentedon Aug 24, 2021
Yes. So v1.15, we have a new table
issue_index
struct name isResourceIndex
which has no primary key. But for MySQL DB cluster, a primary key is necessary? (I'm not familiar with MySQL DB cluster)So
MySQL DB cluster
is never the design target but it works before v1.15. Should we add a primary key forResourceIndex
and supportMySQL DB cluster
officially?aqos156 commentedon Aug 24, 2021
cboylan commentedon Aug 24, 2021
I'm not database expert but I don't think this is
MySQL DB cluster
specific and applies to MySQL and MariaDB generally. It is just that typically MySQL doesn't require you to have aPrimary Key
and will create one for you when you don't specify one. However, in many circumstances this is problematic so newer MySQL (viasql_require_primary_key
) and MariaDB (viainnodb_force_primary_key
) can force you to create them.It sounds like DigitalOcean's hosted databases have made this choice for users.
Rather than testing and supporting
MySQL DB cluster
specifically you may want to set those vars when using MySQL and MariaDB and maintain compatibility that way.This writeup tries to cover the why and how of this.
aqos156 commentedon Aug 24, 2021
Setting these variables is sometimes not an option, because these variables are managed by the provider who uses them to manage clustering and another link
zeripath commentedon Aug 24, 2021
The group_id may as well be a primary key - it has an unique index on it.
cboylan commentedon Aug 24, 2021
Yes, I was suggesting that Gitea may want to set the variables when testing MySQL/MariaDB support rather than figuring out a Galera cluster and testing with that. Primary keys are important to clustered mysql to ensure that rows can be deleted and that you get consistent order of returned data, but flipping these flags on a single database server is probably sufficient for avoiding this incompatibility in the future.
Add primary_key to issue_index
Add primary_key to issue_index (#16813)
Add primary_key to issue_index (go-gitea#16813)
Add primary_key to issue_index (#16813) (#16820)