RESOLVED: Gitea DB Migration Failure DockerImage is Latest

Hello, my Gitea Docker image is constantly restarting. I have attempted to go through the logs and this is what I have discovered it appears to be an internal gitea db migration. Firstly some info:

I have a docker image that is automatically update to latest images of both MariaDB and Gitea. So as of posting, it looks to be

Gitea version 1.16.0+rc1 built with GNU Make 4.3, go1.17.6 : bindata, timetzdata, sqlite, sqlite_unlock_notify

MariaDb version 191

I do not access this service regularly and so do not know when this started happening, below is the logs.

2022/01/25 12:09:37 ...dules/setting/log.go:330:newLogService() [I] Gitea Log Mode: File(File:)
2022/01/25 12:09:37 ...dules/setting/log.go:246:generateNamedLogger() [I] Router Log: Console(console:)
2022/01/25 12:09:37 ...les/setting/cache.go:78:newCacheService() [I] Cache Service Enabled
2022/01/25 12:09:37 ...les/setting/cache.go:93:newCacheService() [I] Last Commit Cache Service Enabled
2022/01/25 12:09:37 ...s/setting/session.go:75:newSessionService() [I] Session Service Enabled
2022/01/25 12:09:37 ...es/setting/mailer.go:145:newNotifyMailService() [W] Notify Mail Service: Mail Service is not enabled
2022/01/25 12:09:37 ...s/storage/storage.go:171:initAttachments() [I] Initialising Attachment storage with type:
2022/01/25 12:09:37 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/attachments
2022/01/25 12:09:37 ...s/storage/storage.go:165:initAvatars() [I] Initialising Avatar storage with type:
2022/01/25 12:09:37 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/avatars
2022/01/25 12:09:37 ...s/storage/storage.go:183:initRepoAvatars() [I] Initialising Repository Avatar storage with type:
2022/01/25 12:09:37 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-avatars
2022/01/25 12:09:37 ...s/storage/storage.go:177:initLFS() [I] Initialising LFS storage with type:
2022/01/25 12:09:37 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/git/lfs
2022/01/25 12:09:37 ...s/storage/storage.go:189:initRepoArchives() [I] Initialising Repository Archive storage with type:
2022/01/25 12:09:37 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-archive
2022/01/25 12:09:37 routers/init.go:130:GlobalInitInstalled() [I] SQLite3 support is enabled
2022/01/25 12:09:37 routers/common/db.go:20:InitDBEngine() [I] Beginning ORM engine initialization.
2022/01/25 12:09:37 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #1/10...
2022/01/25 12:09:37 cmd/web.go:153:runWeb() [I] PING DATABASE mysql
2022/01/25 12:09:37 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: dial tcp 172.29.72.2:3306: connect: connection refused
2022/01/25 12:09:37 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/01/25 12:09:40 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #2/10...
2022/01/25 12:09:40 cmd/web.go:153:runWeb() [I] PING DATABASE mysql
2022/01/25 12:09:40 ...ations/migrations.go:425:Migrate() [I] [SQL] SELECT `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? and `TABLE_NAME`=? [gitea version] - 318.592µs
2022/01/25 12:09:40 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version id] - 485.266µs
2022/01/25 12:09:40 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version version] - 426.096µs
2022/01/25 12:09:40 ...orm@v1.2.5/engine.go:1139:Get() [I] [SQL] SELECT `id`, `version` FROM `version` WHERE `id`=? LIMIT 1 [1] - 358.149µs
2022/01/25 12:09:40 ...ations/migrations.go:462:Migrate() [I] Migration[191]: Alter issue/comment table TEXT fields to LONGTEXT
2022/01/25 12:09:40 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] BEGIN TRANSACTION [] - 51.389µs
2022/01/25 12:09:40 ...ations/migrations.go:465:Migrate() [I] [SQL] ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT [] - 80.750783ms
2022/01/25 12:09:40 ...ations/migrations.go:465:Migrate() [I] [SQL] ROLLBACK [] - 74.805µs
2022/01/25 12:09:40 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: migrate: migration[191]: Alter issue/comment table TEXT fields to LONGTEXT failed: Error 1025: Error on rename of './gitea/issue' to './gitea/#sql-backup-1-3' (errno: 168 "Unknown (generic) error from engine")
2022/01/25 12:09:40 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/01/25 12:09:43 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #3/10...
2022/01/25 12:09:43 cmd/web.go:153:runWeb() [I] PING DATABASE mysql
2022/01/25 12:09:43 ...ations/migrations.go:425:Migrate() [I] [SQL] SELECT `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? and `TABLE_NAME`=? [gitea version] - 251.613µs
2022/01/25 12:09:43 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version id] - 417.096µs
2022/01/25 12:09:43 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version version] - 428.965µs
2022/01/25 12:09:43 ...orm@v1.2.5/engine.go:1139:Get() [I] [SQL] SELECT `id`, `version` FROM `version` WHERE `id`=? LIMIT 1 [1] - 201.295µs
2022/01/25 12:09:43 ...ations/migrations.go:462:Migrate() [I] Migration[191]: Alter issue/comment table TEXT fields to LONGTEXT
2022/01/25 12:09:43 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] BEGIN TRANSACTION [] - 66.615µs
2022/01/25 12:09:43 ...ations/migrations.go:465:Migrate() [I] [SQL] ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT [] - 61.509018ms
2022/01/25 12:09:43 ...ations/migrations.go:465:Migrate() [I] [SQL] ROLLBACK [] - 60.75µs
2022/01/25 12:09:43 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: migrate: migration[191]: Alter issue/comment table TEXT fields to LONGTEXT failed: Error 1025: Error on rename of './gitea/issue' to './gitea/#sql-backup-1-4' (errno: 168 "Unknown (generic) error from engine")
2022/01/25 12:09:43 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/01/25 12:09:46 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #4/10...
2022/01/25 12:09:46 cmd/web.go:153:runWeb() [I] PING DATABASE mysql
2022/01/25 12:09:46 ...ations/migrations.go:425:Migrate() [I] [SQL] SELECT `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? and `TABLE_NAME`=? [gitea version] - 251.869µs
2022/01/25 12:09:46 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version id] - 415.879µs
2022/01/25 12:09:46 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version version] - 392.563µs
2022/01/25 12:09:46 ...orm@v1.2.5/engine.go:1139:Get() [I] [SQL] SELECT `id`, `version` FROM `version` WHERE `id`=? LIMIT 1 [1] - 223.235µs
2022/01/25 12:09:46 ...ations/migrations.go:462:Migrate() [I] Migration[191]: Alter issue/comment table TEXT fields to LONGTEXT
2022/01/25 12:09:46 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] BEGIN TRANSACTION [] - 57.059µs
2022/01/25 12:09:46 ...ations/migrations.go:465:Migrate() [I] [SQL] ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT [] - 48.718495ms
2022/01/25 12:09:46 ...ations/migrations.go:465:Migrate() [I] [SQL] ROLLBACK [] - 69.68µs
2022/01/25 12:09:46 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: migrate: migration[191]: Alter issue/comment table TEXT fields to LONGTEXT failed: Error 1025: Error on rename of './gitea/issue' to './gitea/#sql-backup-1-5' (errno: 168 "Unknown (generic) error from engine")
2022/01/25 12:09:46 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/01/25 12:09:49 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #5/10...
2022/01/25 12:09:49 cmd/web.go:153:runWeb() [I] PING DATABASE mysql
2022/01/25 12:09:49 ...ations/migrations.go:425:Migrate() [I] [SQL] SELECT `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? and `TABLE_NAME`=? [gitea version] - 229.364µs
2022/01/25 12:09:49 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version id] - 398.817µs
2022/01/25 12:09:49 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? [gitea version version] - 353.5µs
2022/01/25 12:09:49 ...orm@v1.2.5/engine.go:1139:Get() [I] [SQL] SELECT `id`, `version` FROM `version` WHERE `id`=? LIMIT 1 [1] - 199.194µs
2022/01/25 12:09:49 ...ations/migrations.go:462:Migrate() [I] Migration[191]: Alter issue/comment table TEXT fields to LONGTEXT
2022/01/25 12:09:49 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] BEGIN TRANSACTION [] - 61.809µs
2022/01/25 12:09:49 ...ations/migrations.go:465:Migrate() [I] [SQL] ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT [] - 57.17632ms
2022/01/25 12:09:49 ...ations/migrations.go:465:Migrate() [I] [SQL] ROLLBACK [] - 72.708µs
2022/01/25 12:09:49 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: migrate: migration[191]: Alter issue/comment table TEXT fields to LONGTEXT failed: Error 1025: Error on rename of './gitea/issue' to './gitea/#sql-backup-1-6' (errno: 168 "Unknown (generic) error from engine")
2022/01/25 12:09:49 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds

Any guidance on how to resolve this would be greatly appreciated.

I have been able to resolve this issue after changing my focus from GITEA to MARIADB.

I had to run mysql_upgrade -p in bash terminal of the MARIADB container and also delete the associated volume for it.

I was originally on GOGS/MySQL and then migrated to Gitea/MySQL when it started and then Gitea/MariaDB. I have been using this container for a few years now and wonder if there was perhaps a upgrade step I missed along the way and with Gitea 1.16, it finally broke.

1 Like