migration from version 1.8.3 to version 1.9.0 fails #3708

Closed
opened 2025-11-02 05:22:27 -06:00 by GiteaMirror · 25 comments
Owner

Originally created by @wumpz on GitHub (Aug 1, 2019).

  • Gitea version (or commit ref): 1.9.0
  • Operating system: linux / docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I have a running 1.8.3 gitea docker server. All works fine. Now I wanted to upgrade to the new version 1.9.0. The server seems to be in a neverending loop initializing itself. All I see in my docker logs is repeatingly endless.

gitea_server_1  | 2019/08/01 05:59:58 ...dules/setting/git.go:83:newGit() [I] Git Version: 2.22.0, Wire Protocol Version 2 Enabled
gitea_server_1  | 2019/08/01 05:59:58 routers/init.go:72:GlobalInit() [T] AppPath: /app/gitea/gitea
gitea_server_1  | 2019/08/01 05:59:58 routers/init.go:73:GlobalInit() [T] AppWorkPath: /app/gitea
gitea_server_1  | 2019/08/01 05:59:58 routers/init.go:74:GlobalInit() [T] Custom path: /data/gitea
gitea_server_1  | 2019/08/01 05:59:58 routers/init.go:75:GlobalInit() [T] Log path: /data/gitea/log
gitea_server_1  | 2019/08/01 05:59:58 ...dules/setting/log.go:226:newLogService() [I] Gitea v1.9.0 built with GNU Make 4.2.1, go1.12.7 : bindata, sqlite, sqlite_unlock_notify

Where should I look for additional informations? Logs?

Originally created by @wumpz on GitHub (Aug 1, 2019). - Gitea version (or commit ref): 1.9.0 - Operating system: linux / docker - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description I have a running 1.8.3 gitea docker server. All works fine. Now I wanted to upgrade to the new version 1.9.0. The server seems to be in a neverending loop initializing itself. All I see in my docker logs is repeatingly endless. ``` gitea_server_1 | 2019/08/01 05:59:58 ...dules/setting/git.go:83:newGit() [I] Git Version: 2.22.0, Wire Protocol Version 2 Enabled gitea_server_1 | 2019/08/01 05:59:58 routers/init.go:72:GlobalInit() [T] AppPath: /app/gitea/gitea gitea_server_1 | 2019/08/01 05:59:58 routers/init.go:73:GlobalInit() [T] AppWorkPath: /app/gitea gitea_server_1 | 2019/08/01 05:59:58 routers/init.go:74:GlobalInit() [T] Custom path: /data/gitea gitea_server_1 | 2019/08/01 05:59:58 routers/init.go:75:GlobalInit() [T] Log path: /data/gitea/log gitea_server_1 | 2019/08/01 05:59:58 ...dules/setting/log.go:226:newLogService() [I] Gitea v1.9.0 built with GNU Make 4.2.1, go1.12.7 : bindata, sqlite, sqlite_unlock_notify ``` Where should I look for additional informations? Logs?
GiteaMirror added the type/bug label 2025-11-02 05:22:27 -06:00
Author
Owner

@wumpz commented on GitHub (Aug 1, 2019):

By the way, switching back to version 1.8.3 the server starts again like a breeze.

@wumpz commented on GitHub (Aug 1, 2019): By the way, switching back to version 1.8.3 the server starts again like a breeze.
Author
Owner

@wumpz commented on GitHub (Aug 1, 2019):

Within the log file, I found this SQL after which a rollback is done.

2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION
2019/08/01 06:00:25 ...xorm/session_find.go:199:noCacheFind() [I] [SQL] SELECT `id`, `uid`, `name`, `sha1`, `token_hash`, `token_salt`, `token_last_eight`, `created_unix`, `updated_unix` FROM `access_token` LIMIT 100
2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] COMMIT
2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION
2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_list(`access_token`)
2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_updated_unix`)
2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_created_unix`)
2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_uid`)
2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] SELECT sql FROM sqlite_master WHERE tbl_name='access_token' and type='table'
2019/08/01 06:00:25 .../xorm/session_raw.go:226:Exec() [I] [SQL] CREATE TABLE `new_access_token_new` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `uid` INTEGER NULL, `name` TEXT NULL, `token_hash` TEXT NULL, `token_salt` TEXT NULL, `token_last_eight` TEXT NULL, `created_unix` INTEGER NULL, `updated_unix` INTEGER NULL,
2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] ROLL BACK
2019/08/01 06:00:25 routers/init.go:58:initDBEngine() [I] Backing off for 3 seconds
2019/08/01 06:00:28 routers/init.go:51:initDBEngine() [I] ORM engine initialization attempt #2/10...

@wumpz commented on GitHub (Aug 1, 2019): Within the log file, I found this SQL after which a rollback is done. ``` 2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION 2019/08/01 06:00:25 ...xorm/session_find.go:199:noCacheFind() [I] [SQL] SELECT `id`, `uid`, `name`, `sha1`, `token_hash`, `token_salt`, `token_last_eight`, `created_unix`, `updated_unix` FROM `access_token` LIMIT 100 2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] COMMIT 2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION 2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_list(`access_token`) 2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_updated_unix`) 2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_created_unix`) 2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] PRAGMA index_info(`IDX_access_token_uid`) 2019/08/01 06:00:25 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] SELECT sql FROM sqlite_master WHERE tbl_name='access_token' and type='table' 2019/08/01 06:00:25 .../xorm/session_raw.go:226:Exec() [I] [SQL] CREATE TABLE `new_access_token_new` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `uid` INTEGER NULL, `name` TEXT NULL, `token_hash` TEXT NULL, `token_salt` TEXT NULL, `token_last_eight` TEXT NULL, `created_unix` INTEGER NULL, `updated_unix` INTEGER NULL, 2019/08/01 06:00:25 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] ROLL BACK 2019/08/01 06:00:25 routers/init.go:58:initDBEngine() [I] Backing off for 3 seconds 2019/08/01 06:00:28 routers/init.go:51:initDBEngine() [I] ORM engine initialization attempt #2/10... ```
Author
Owner

@zeripath commented on GitHub (Aug 1, 2019):

I suspect this is an error in droptables - #6849 but why it's not been caught by our migration tests I don't understand.

@zeripath commented on GitHub (Aug 1, 2019): I suspect this is an error in droptables - #6849 but why it's not been caught by our migration tests I don't understand.
Author
Owner

@wumpz commented on GitHub (Aug 1, 2019):

@zeripath So can I provide additional information to tackle this problem? I really want to upgrade. ;)

@wumpz commented on GitHub (Aug 1, 2019): @zeripath So can I provide additional information to tackle this problem? I really want to upgrade. ;)
Author
Owner

@phamilton4321 commented on GitHub (Aug 4, 2019):

Any workaround available? I'm on 1.8.3 with sqlite and can't upgrade to 1.9.0 too because of database errors...

@phamilton4321 commented on GitHub (Aug 4, 2019): Any workaround available? I'm on 1.8.3 with sqlite and can't upgrade to 1.9.0 too because of database errors...
Author
Owner

@wumpz commented on GitHub (Aug 4, 2019):

@phamilton4321 as far as I know, the patch is already available and I think it will be there in the next release.

@wumpz commented on GitHub (Aug 4, 2019): @phamilton4321 as far as I know, the patch is already available and I think it will be there in the next release.
Author
Owner

@phamilton4321 commented on GitHub (Aug 4, 2019):

@wumpz okay, thx. I'll stay patient, 1.8.3 Ist more than awesome for me 😁

@phamilton4321 commented on GitHub (Aug 4, 2019): @wumpz okay, thx. I'll stay patient, 1.8.3 Ist more than awesome for me 😁
Author
Owner

@lonix1 commented on GitHub (Aug 5, 2019):

I have the same problem when upgrading from 1.7.5

@lonix1 commented on GitHub (Aug 5, 2019): I have the same problem when upgrading from 1.7.5
Author
Owner

@wumpz commented on GitHub (Aug 6, 2019):

In which version will this be integrated?

@wumpz commented on GitHub (Aug 6, 2019): In which version will this be integrated?
Author
Owner

@lafriks commented on GitHub (Aug 6, 2019):

1.9.1

@lafriks commented on GitHub (Aug 6, 2019): 1.9.1
Author
Owner

@phamilton4321 commented on GitHub (Aug 15, 2019):

Did updating from 1.8.3 to 1.9.1 work for everybody? I'm having the same error as I had while updating to 1.9.0...

@phamilton4321 commented on GitHub (Aug 15, 2019): Did updating from 1.8.3 to 1.9.1 work for everybody? I'm having the same error as I had while updating to 1.9.0...
Author
Owner

@wumpz commented on GitHub (Aug 15, 2019):

Update from 1.8.3 to 1.9.1 worked. Gitea started so far I understand it. The webfront end pops up and shows version 1.9.1. No more error messages within the log.

I am using a docker image of Gitea. Maybe there is still a difference.

@wumpz commented on GitHub (Aug 15, 2019): Update from 1.8.3 to 1.9.1 worked. Gitea started so far I understand it. The webfront end pops up and shows version 1.9.1. No more error messages within the log. I am using a docker image of Gitea. Maybe there is still a difference.
Author
Owner

@phamilton4321 commented on GitHub (Aug 15, 2019):

Okay, then it might be an issue with my current db. I'm going to check if I can fix it manually.
Thanks anyways

Edit: Created an empty database with 1.9.1 and restored my data from gitea dump sql.
All good now on 1.9.1

@phamilton4321 commented on GitHub (Aug 15, 2019): Okay, then it might be an issue with my current db. I'm going to check if I can fix it manually. Thanks anyways Edit: Created an empty database with 1.9.1 and restored my data from gitea dump sql. All good now on 1.9.1
Author
Owner

@dunklesToast commented on GitHub (Oct 11, 2019):

Upgraded from 1.4.3 to 1.9.3. Having the same issue

2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] COMMIT
2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION
2019/10/11 16:19:08 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] SHOW INDEX FROM issue WHERE column_name IN ('assignee_id')
2019/10/11 16:19:08 .../xorm/session_raw.go:226:Exec() [I] [SQL] DROP INDEX `` ON `issue`
2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] ROLL BACK
2019/10/11 16:19:08 routers/init.go:86:GlobalInit() [F] ORM engine initialization failed: migrate: do migrate: Error 1091: Can't DROP ''; check that column/key exists
@dunklesToast commented on GitHub (Oct 11, 2019): Upgraded from 1.4.3 to 1.9.3. Having the same issue ``` 2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] COMMIT 2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] BEGIN TRANSACTION 2019/10/11 16:19:08 .../xorm/session_raw.go:143:queryBytes() [I] [SQL] SHOW INDEX FROM issue WHERE column_name IN ('assignee_id') 2019/10/11 16:19:08 .../xorm/session_raw.go:226:Exec() [I] [SQL] DROP INDEX `` ON `issue` 2019/10/11 16:19:08 ...xorm/xorm/session.go:845:saveLastSQL() [I] [SQL] ROLL BACK 2019/10/11 16:19:08 routers/init.go:86:GlobalInit() [F] ORM engine initialization failed: migrate: do migrate: Error 1091: Can't DROP ''; check that column/key exists ```
Author
Owner

@guillep2k commented on GitHub (Oct 11, 2019):

@dunklesToast Please try migrating to intermediate versions (especially before 1.6.0) and let us know which was the latest you could upgrade to. Also, if you could try "SELECT version FROM version", it would help.

@guillep2k commented on GitHub (Oct 11, 2019): @dunklesToast Please try migrating to intermediate versions (especially before 1.6.0) and let us know which was the latest you could upgrade to. Also, if you could try "SELECT version FROM version", it would help.
Author
Owner

@zeripath commented on GitHub (Oct 11, 2019):

@dunklesToast I think I might understand what's going on here!

What database are you using? It's MYSQL right?

@zeripath commented on GitHub (Oct 11, 2019): @dunklesToast I think I might understand what's going on here! What database are you using? It's MYSQL right?
Author
Owner

@zeripath commented on GitHub (Oct 11, 2019):

I think it's looking for the index, not finding one, but then still trying to remove the index

@zeripath commented on GitHub (Oct 11, 2019): I think it's looking for the index, not finding one, but then still trying to remove the index
Author
Owner

@dunklesToast commented on GitHub (Oct 11, 2019):

@guillep2k tried that already. With Version 1.5.0 I am getting this error:

Log Mode: File(Info)
2019/10/12 00:00:22 [I] XORM Log Mode: File(Info)
2019/10/12 00:00:22 [I] Cache Service Enabled
2019/10/12 00:00:22 [I] Session Service Enabled
2019/10/12 00:00:22 [I] Migration: Reformat and remove incorrect topics
2019/10/12 00:00:22 [I] This migration could take up to minutes, please be patient.
2019/10/12 00:00:22 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Sync2: Error 1071: Specified key was too long; max key length is 767 bytes

@zeripath Yep, MySQL. Do you think adding the index manually will fix this?

@dunklesToast commented on GitHub (Oct 11, 2019): @guillep2k tried that already. With Version 1.5.0 I am getting this error: ``` Log Mode: File(Info) 2019/10/12 00:00:22 [I] XORM Log Mode: File(Info) 2019/10/12 00:00:22 [I] Cache Service Enabled 2019/10/12 00:00:22 [I] Session Service Enabled 2019/10/12 00:00:22 [I] Migration: Reformat and remove incorrect topics 2019/10/12 00:00:22 [I] This migration could take up to minutes, please be patient. 2019/10/12 00:00:22 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Sync2: Error 1071: Specified key was too long; max key length is 767 bytes ``` @zeripath Yep, MySQL. Do you think adding the index manually will fix this?
Author
Owner

@zeripath commented on GitHub (Oct 11, 2019):

The causative code is:

ac3613b791/models/migrations/migrations.go (L398-L423)

In particular
ac3613b791/models/migrations/migrations.go (L406-L407)

I think I thought it would not return any results if there was no index. Clearly I was wrong.

Simple bug fix add between 406 and 407:

if strings.Trimspace(indexname) == "" {
  continue
}

Probably doesn't need the Trimspace.

Anyone fancy putting a PR up?

@zeripath commented on GitHub (Oct 11, 2019): The causative code is: https://github.com/go-gitea/gitea/blob/ac3613b791884f29c386bda2ccaad5c7434d822c/models/migrations/migrations.go#L398-L423 In particular https://github.com/go-gitea/gitea/blob/ac3613b791884f29c386bda2ccaad5c7434d822c/models/migrations/migrations.go#L406-L407 I think I thought it would not return any results if there was no index. Clearly I was wrong. Simple bug fix add between 406 and 407: ```go if strings.Trimspace(indexname) == "" { continue } ``` Probably doesn't need the Trimspace. Anyone fancy putting a PR up?
Author
Owner

@guillep2k commented on GitHub (Oct 11, 2019):

A quick PR? NP. 😁

@guillep2k commented on GitHub (Oct 11, 2019): A quick PR? NP. 😁
Author
Owner

@dunklesToast commented on GitHub (Oct 11, 2019):

Thanks!
So now I have to wait until this is merged, a new version was compiled and then can I update or is there any hot fix / dirty patch so I can migrate to 1.9?

@dunklesToast commented on GitHub (Oct 11, 2019): Thanks! So now I have to wait until this is merged, a new version was compiled and then can I update or is there any hot fix / dirty patch so I can migrate to 1.9?
Author
Owner

@guillep2k commented on GitHub (Oct 11, 2019):

@dunklesToast First the PR must be approved. Then one of the owners will assign a milestone for it. Depending on the milestone they may request a backport. And then we must wait until the target release is done.

I don't know how desperate you are 😁, but if you don't want to wait, you could pull the 1.9.4 tag, apply the diff from that PR (it's only a couple of lines), compile and run. That should make it pass the upgrade part. If it works, then you can download and use a vanilla 1.9.4 to stay "standard".

@guillep2k commented on GitHub (Oct 11, 2019): @dunklesToast First the PR must be approved. Then one of the owners will assign a milestone for it. Depending on the milestone they may request a backport. And then we must wait until the target release is done. I don't know how desperate you are 😁, but if you don't want to wait, you could pull the 1.9.4 tag, apply the diff from that PR (it's only a couple of lines), compile and run. That should make it pass the upgrade part. If it works, then you can download and use a vanilla 1.9.4 to stay "standard".
Author
Owner

@robin-thoni commented on GitHub (Feb 6, 2020):

What's the status on this? I'm also trying to upgrade from 1.7 and getting the same loop...

@robin-thoni commented on GitHub (Feb 6, 2020): What's the status on this? I'm also trying to upgrade from `1.7` and getting the same loop...
Author
Owner

@jolheiser commented on GitHub (Feb 6, 2020):

@robin-thoni This issue has (reportedly) been fixed.
Can you please open a new issue with more details? Feel free to link to this one for reference.

@jolheiser commented on GitHub (Feb 6, 2020): @robin-thoni This issue has (reportedly) been fixed. Can you please open a new issue with more details? Feel free to link to this one for reference.
Author
Owner

@zeripath commented on GitHub (Feb 7, 2020):

Please only migrate to the last point release of a series - so from 1.8.x to 1.9.5 not to 1.9.0. The broken migrations can only be fixed in later point releases - we can't re-release.

@zeripath commented on GitHub (Feb 7, 2020): Please only migrate to the last point release of a series - so from 1.8.x to 1.9.5 not to 1.9.0. The broken migrations can only be fixed in later point releases - we can't re-release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3708