gogs: Push rejected due to database lock

  • Gogs version (or commit ref): 0.9.71.0809
  • Git version: 2.7.4
  • Operating system: Ubuntu 16.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • SQLite
  • Can you reproduce the bug at https://try.gogs.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

When trying to push my latest changes to the gogs hosted repository, the update was declined due to a locked database. The push command show following errors:

$ git push
Zähle Objekte: 367, Fertig.
Delta compression using up to 8 threads.
Komprimiere Objekte: 100% (70/70), Fertig.
Schreibe Objekte: 100% (367/367), 313.59 KiB | 0 bytes/s, Fertig.
Total 367 (delta 178), reused 347 (delta 165)
remote: error: hook declined to update refs/heads/master
Gogs: Internal error
UpdatePublicKey: database is locked
To ssh://host/user/repository.git
 ! [remote rejected] master -> master (hook declined)
error: Fehler beim Versenden einiger Referenzen nach 'ssh://git@host/user/repository.git'

On server-side the update.log showed following entry

2016/08/19 13:28:38 [...s/gogs/cmd/update.go:54 runUpdate()] [F] AddUpdateTask: database is locked

After a restart of the gogs server, I could do the push.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

This issue some kind of show stopper. When the database gets locked no further respository actions are possible. The only remedy is to restart the gogs server. Since there’s no reproducable scenario, the emergency solution is to migrate the sqlite3 database to MySQL.

With the help of the pythom dump conversion script an sqlite3 dump can be converted to a MySQL dump.

Since my gogs database has some TEXT fields where MySQL would have VARCHAR additional conversion is necessary. However the whole conversion can be done within one bash line:

$ sqlite3 gogs.db .dump | ./sqlite3-to-mysql.py -u gogs -p newdbpassword -d gogs | sed 's/UUID/TEXT/g' | sed 's/TEXT/VARCHAR(255)/g' | sed 's/`avatar` VARCHAR(255)/`avatar` VARCHAR(2048)/g' | sed 's/`content` VARCHAR(255)/`content` TEXT/g' | sed 's/`url` VARCHAR(255)/`url` TEXT/g' | sed 's/`cfg` VARCHAR(255)/`cfg` TEXT/g' | sed 's/`description` VARCHAR(255)/`description` TEXT/g' | sed 's/`note` VARCHAR(255)/`note` TEXT/g' | sed 's/`secret` VARCHAR(255)/`secret` TEXT/g' | sed 's/`events` VARCHAR(255)/`events` TEXT/g' | sed 's/`meta` VARCHAR(255)/`meta` TEXT/g' | mysql --user=root --password=rootpassword --default-character-set=utf8

Maybe this helps others with the same problem.

Migration between different databases and database types can be done using gogs’ backup and restore function. See https://github.com/gogits/gogs/issues/2924#issuecomment-287216941 and How to backup, restore and migrate.

Thanks for your DB-migration tool!