New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All database tables doesn't have a primary key column #12971
Comments
I faced the same issue running MySQL > 8.0.13 with sql_require_primary_key=ON |
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes grafana#12971
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes grafana#12971
I'm facing the same issue, DigitalOcean Managed MySQL databases require a primary key. So I can't use grafana with this because the tables have no primary keys defined. Can this be fixed? Any reason for specifically not adding primary keys? |
I had to dump the sql schema and then add some primary keys on the missing tables then import. It would be great if this was just part of the original schema. |
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes #12971 Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes #12971 Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes #12971 Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
The annotation_tag and alert_rule_tag tables did not have PRIMARY KEY defined what cause problems with migration to MariaDB with Galera setup with innodb_force_primary_key=1 Or MySQL > 8.0.13 with sql_require_primary_key=ON Which can manifest as follows: MariaDB Error 1173: This table type requires a primary key MySQL ERROR 3750 (HY000): Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Extra reading for curious: https://jfg-mysql.blogspot.com/2017/08/danger-no-pk-with-RBR-and-mariadb-protection.html Fixes #12971 Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
@marefr I'm not sure this is fixed, with an empty database:
If I'm reading the code right, the temporary table used for migration doesn't have a primary key, so the migration fails. |
Anyone who comes across this from Google:
|
This issue was closed as of #22255, but one thing not addressed by that PR is creating all tables initially with primary keys. What Grafana does now is:
However, if you are running using MySQL with Is there any reason to not change things so that the initial schema created (for a fresh Grafana instance) for alert_rule_tag and annotation_tag contain primary keys. The workaround provided by @Silvenga and others technically work, but seem like unnecessary hoops to have to jump through. |
fix mysql PrimaryKey grafana#12971
When using Grafana with MariaDB with Galera cluster the database migration/creation fails because of a the setting
innodb_force_primary_key=1
, which is required for Galera cluster to work properly. You don't need to set up a Galera cluster to reproduce this issue, you can do it by setting that property on a normal MariaDB instance.I have corrected the issue in PR 12970.
What Grafana version are you using?
5.2.2
What OS are you running grafana on?
RHEL 7.3
What did you do?
bin/grafana-server web
What was the expected result?
Successful service start
What happened instead?
The text was updated successfully, but these errors were encountered: