Grafana Update Failed

Trying to update grafana from grafana-4.6.3-1.x86_64 to grafana-5.0.3-1.x86_64
[root@ip-10-0-0-207 GrafanaScripts]# grafana-server -v Version 4.6.3 (commit: 7a06a47)

[root@ip-10-0-0-207 grafana]# grafana-server -v Version 5.0.3 (commit: 91162f3)

Update grafana from repo via yum update
After that grafana start failed with errors in log file :
t=2018-03-22T15:43:11+0000 lvl=info msg="Executing migration" logger=migrator id="Remove unique index org_id_slug" t=2018-03-22T15:43:11+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug' ; check that column/key exists" t=2018-03-22T15:43:11+0000 lvl=eror msg="Exec failed" logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEXUQE
_dashboard_org_id_slugONdashboard" t=2018-03-22T15:43:11+0000 lvl=eror msg="Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists\n"

t=2018-03-22T15:43:12+0000 lvl=info msg="Executing migration" logger=migrator id="Remove unique index org_id_slug" t=2018-03-22T15:43:12+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" t=2018-03-22T15:43:12+0000 lvl=eror msg="Exec failed" logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEXUQE_dashboard_org_id_slugONdashboard" t=2018-03-22T15:43:12+0000 lvl=eror msg="Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists\n"

t=2018-03-22T15:43:12+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" t=2018-03-22T15:43:12+0000 lvl=eror msg="Exec failed" logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEXUQE_dashboard_org_id_slugONdashboard" t=2018-03-22T15:43:12+0000 lvl=eror msg="Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists\n"

t=2018-03-22T15:43:12+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" t=2018-03-22T15:43:12+0000 lvl=eror msg="Exec failed" logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEXUQE_dashboard_org_id_slugONdashboard" t=2018-03-22T15:43:12+0000 lvl=eror msg="Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists\n"

t=2018-03-22T15:43:12+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Remove unique index org_id_slug" error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" t=2018-03-22T15:43:12+0000 lvl=eror msg="Exec failed" logger=migrator error="Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists" sql="DROP INDEXUQE_dashboard_org_id_slugONdashboard" t=2018-03-22T15:43:12+0000 lvl=eror msg="Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration failed err: Error 1091: Can't DROP 'UQE_dashboard_org_id_slug'; check that column/key exists\n"

Could someone help me with this problem ?

That looks serious and also quite strange - don’t think we have seen anyone else with this error. What database are you using? (If it is mysql or postgres then please provide the version number of the database as well).

Edit: see below

The simplest way to resolve the problem is likely going to be to run this SQL to create the index that the migrator expects to be present:

ADD UNIQUE INDEX `UQE_dashboard_org_id_slug` ON `dashboard` (`org_id`, `slug`);

Then restart Grafana and the migration should run successfully.

At first I’m using sqlite db after that convert all db to Mysql and run all stuff on mysql 5.7

How did you convert to MySQL from sqlite?

Using this service https://www.rebasedata.com/convert-sqlite-to-mysql-online
Because all console tools didn’t help me convert sqlite db with properly syntax

Ok, that is likely the source of your problem. The best way to convert is to follow the instructions at Migrating grafana data to new database

Using that approach will give you exactly the database structure that Grafana expects, where the database conversion likely created things slightly differently.

Ohh, thanks a lot Dan.
Good solution but so late for me :worried:
Because after migration from sqlite to mysql I have added a lot of metrics, but I think during two hours I could configure it again.
Thanks, again, tommorow morning I try script which you show me, because now in Ukraine 9 pm :slightly_smiling_face:

You could try dumping only the data from the MySQL database, then starting Grafana with a fresh database and importing the data again. Assuming your database is called grafana this should give you a usable dump:

mysqldump -n -t -c --ignore-table=grafana.migration_log grafana > grafana.sql

1 Like

Hi again !
Dump only data from mysql db after that start with fresh db, try to import data again.
At first was problem with already present default data in user table , org and org_user
Delete this data and try again, faced with indexes problem, delete all indexes from user table , org and org_user
Try again and got an error :
[ERROR in query 108] Table 'grafana.sqlite_sequence' doesn't exist

So, I ignore this error and everything works fine. Also I successfully update the grafana server, but now just staging, now try do the same with prod-grafana