Upgrade to Grafana 13.1.1 got DB Issue

  • What Grafana version and what operating system are you using?
    version 12.4.1, with official docker image deployed in K8s

  • What are you trying to achieve?
    upgrade from 12.4.1 to 13.1.1

  • How are you trying to achieve it?
    Update the image tag in deployment configuration in K8s.

  • What happened?
    DB error shown as below:
    Error: ✗ migration failed (id = Increase precision of team.updated to DATETIME(3)): pq: duplicate key value violates unique constraint “migration_log_pkey” (23505)

    I have checked our postgresql db of the migration_log table, but can’t find this item.
    id = Increase precision of team.updated to DATETIME(3)

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

Thanks, @kimberlyyerhot63 .

I will try very new version till this issue fixed.

One possibility is that the sequence backing migration_log.id is out of sync with the table, since that can result in duplicate primary key errors. However, the error alone doesn’t confirm that’s the cause.

Could you also share →

the full Grafana startup log from Starting DB migrations through the duplicate key value violates unique constraint "migration_log_pkey" error, and
whether only one Grafana instance/pod was running while the upgrade was performing the database migration?

That should help determine whether this is a sequence issue, concurrent migration attempts, or another migration problem.

Thanks, @infofcc3 .

You give me an idea to rollback grafana db to an older version and seems works.

Please close the ticket.