Skip to content

web.go PANIC on upgrade from 1.20.6 to 1.21 #28705

@sysnux

Description

@sysnux

Description

Trying to upgrade from 1.20.6 to 1.21.3 or 1.21.0, service won't start:

systemd[1]: Started gitea.service - Gitea.
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:242:runWeb() [I] Starting Gitea on PID: 62328
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.21.0 built with GNU Make 4.3, go1.21.4 : bindata, sqlite, sqlite_unlock_notify
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: /usr/local/bin/gitea
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: /var/lib/gitea
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: /var/lib/gitea/custom
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: /etc/gitea/app.ini
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run web server
gitea[62328]: 2024/01/05 09:51:31 routers/init.go:112:InitWebInstalled() [I] Git version: 2.43.0, Wire Protocol Version 2 Enabled (home: /var/lib/gitea/data/home)
gitea[62328]: 2024/01/05 09:51:31 ...les/setting/cache.go:75:loadCacheFrom() [I] Cache Service Enabled
gitea[62328]: 2024/01/05 09:51:31 ...les/setting/cache.go:90:loadCacheFrom() [I] Last Commit Cache Service Enabled
gitea[62328]: 2024/01/05 09:51:31 ...s/setting/session.go:74:loadSessionFrom() [I] Session Service Enabled
gitea[62328]: 2024/01/05 09:51:31 ...es/setting/mailer.go:237:loadMailerFrom() [I] Mail Service Enabled
gitea[62328]: 2024/01/05 09:51:31 ...es/setting/mailer.go:259:loadNotifyMailFrom() [I] Notify Mail Service Enabled
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/attachments
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:166:initAvatars() [I] Initialising Avatar storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/avatars
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:192:initRepoAvatars() [I] Initialising Repository Avatar storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/repo-avatars
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:198:initRepoArchives() [I] Initialising Repository Archive storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/repo-archive
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:208:initPackages() [I] Initialising Packages storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/packages
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:219:initActions() [I] Initialising Actions storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/actions_log
gitea[62328]: 2024/01/05 09:51:31 ...s/storage/storage.go:223:initActions() [I] Initialising ActionsArtifacts storage with type: local
gitea[62328]: 2024/01/05 09:51:31 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/actions_artifacts
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:255:doRun() [D] Queue "notification-service" starts running
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:255:doRun() [D] Queue "mail" starts running
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:255:doRun() [D] Queue "repo-archive" starts running
gitea[62328]: 2024/01/05 09:51:31 routers/init.go:131:InitWebInstalled() [I] SQLite3 support is enabled
gitea[62328]: 2024/01/05 09:51:31 routers/common/db.go:23:InitDBEngine() [I] Beginning ORM engine initialization.
gitea[62328]: 2024/01/05 09:51:31 routers/common/db.go:30:InitDBEngine() [I] ORM engine initialization attempt #1/10...
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:333:doRun() [D] Queue "notification-service" is shutting down
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:333:doRun() [D] Queue "mail" is shutting down
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:334:doRun() [D] Queue "notification-service" stops running
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:333:doRun() [D] Queue "repo-archive" is shutting down
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:334:doRun() [D] Queue "mail" stops running
gitea[62328]: 2024/01/05 09:51:31 ...queue/workergroup.go:334:doRun() [D] Queue "repo-archive" stops running
gitea[62328]: 2024/01/05 09:51:31 ...eful/manager_unix.go:208:handleSignals() [W] PID: 62328. Background context for manager closed - context canceled - Shutting down...
gitea[62328]: 2024/01/05 09:51:31 cmd/web.go:231:func1() [F] PANIC: runtime error: index out of range [0] with length 0
gitea[62328]: /usr/local/go/src/runtime/panic.go:114 (0x43b09b)
gitea[62328]: /source/modules/setting/database.go:171 (0xa59e37)
gitea[62328]: /source/modules/setting/database.go:112 (0xa5982b)
gitea[62328]: /source/models/db/engine.go:97 (0xfc7a36)
gitea[62328]: /source/models/db/engine.go:134 (0xfc7ce8)
gitea[62328]: /source/models/db/engine.go:180 (0xfc81a5)
gitea[62328]: /source/routers/common/db.go:31 (0x24109e4)
gitea[62328]: /source/routers/init.go:65 (0x272a80e)
gitea[62328]: /source/routers/init.go:136 (0x272aed8)
gitea[62328]: /source/cmd/web.go:194 (0x282b038)
gitea[62328]: /source/cmd/web.go:262 (0x282b5fc)
gitea[62328]: /source/cmd/main.go:117 (0x28220cb)
gitea[62328]: /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/command.go:274 (0x13440d7)
gitea[62328]: /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/command.go:267 (0x1344324)
gitea[62328]: /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/app.go:332 (0x1340a56)
gitea[62328]: /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/app.go:309 (0x2822cd8)
gitea[62328]: /source/cmd/main.go:176 (0x2822cbc)
gitea[62328]: /source/main.go:46 (0x2868d58)
gitea[62328]: /usr/local/go/src/runtime/proc.go:267 (0x4400ba)
gitea[62328]: /usr/local/go/src/runtime/asm_amd64.s:1650 (0x473ca0)
systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: gitea.service: Failed with result 'exit-code'.

Reverting to 1.20.6 afterwards works fine.

Gitea Version

1.21.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.43.0

Operating System

Linux Fedora 38

How are you running Gitea?

Running the binary (gitea-1.21.0-linux-amd64 or gitea-1.21.3-linux-amd64), with PostgreSQL (14.10) database.

Database

PostgreSQL

Activity

wxiaoguang

wxiaoguang commented on Jan 6, 2024

@wxiaoguang
Contributor

Regression of #27723

What's your [database] section of the app.ini? Maybe you could try to bypass it by setting a host name for the HOST config.

wxiaoguang

wxiaoguang commented on Jan 6, 2024

@wxiaoguang
Contributor

-> Fix panic when parsing empty pgsql host #28708

sysnux

sysnux commented on Jan 6, 2024

@sysnux
Author

Setting HOST = /var/run/postgresql/ indeed solved the problem. 1.21.3 is running fine now.
The docs are still a bit confusing though. I initially configured HOST = /var/run/postgresql/.s.PGSQL.5432, and got:
routers/init.go:69:mustInitCtx() [F] code.gitea.io/gitea/routers/common.InitDBEngine(ctx) failed: dial unix /var/run/postgresql/.s.PGSQL.5432/.s.PGSQL.5432: connect: not a directory

Thanks for very prompt resolution!

added a commit that references this issue on Jan 6, 2024
4ab323a
added a commit that references this issue on Jan 6, 2024
e75e9a0
added this to the 1.21.4 milestone on Jan 6, 2024
added a commit that references this issue on Jan 6, 2024
7f833d8
added a commit that references this issue on Jan 17, 2024
a4c445e
added a commit that references this issue on Feb 20, 2024
46fa0c1
locked as resolved and limited conversation to collaborators on Feb 21, 2024
added a commit that references this issue on Jan 23, 2025
ad027c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @lunny@wxiaoguang@sysnux

      Issue actions

        web.go PANIC on upgrade from 1.20.6 to 1.21 · Issue #28705 · go-gitea/gitea