Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed migration v67 remove stale watches causes Gitea to not start #5848

Closed
2 of 7 tasks
KubqoA opened this issue Jan 25, 2019 · 14 comments
Closed
2 of 7 tasks

Failed migration v67 remove stale watches causes Gitea to not start #5848

KubqoA opened this issue Jan 25, 2019 · 14 comments
Labels
Milestone

Comments

@KubqoA
Copy link
Contributor

KubqoA commented Jan 25, 2019

Description

I am running mailcow with gitea so I can authenticate users using their mail account. Yesterday I updated my mailcow stack and also Gitea with it. Since then Gitea doesn't launch. I tried to debug it and it looks like it gets stuck when it tries to run migration remove stale watches. If I specify another database file in my app.ini, so that Gitea creates a new one, everything seems to work and Gitea loads without any problems. However this means that I'd lose all my data, which is not a very good solution.

@lafriks
Copy link
Member

lafriks commented Jan 25, 2019

Can you check contents of gitea.log file, it should contain error where it fails

@lafriks lafriks added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Jan 25, 2019
@KubqoA
Copy link
Contributor Author

KubqoA commented Jan 25, 2019

I checked the /var/lib/gitea/gitea/logs/gitea.log, xorm.log and serv.log, but there are no other logs. The log gist I gave you has all the log messages I am able to get my hands on.

@zeripath
Copy link
Contributor

Hmm is this an sqlite database? I wonder if you're hitting a deadlock somehow

@KubqoA
Copy link
Contributor Author

KubqoA commented Jan 25, 2019

Well, if migrating to different type of database is a possible solution I am down for it. However, I don't know would I do such a thing.

@typeless
Copy link
Contributor

@KubqoA What was the version before the migration?

@zeripath
Copy link
Contributor

The logs you've printed refer to migration v67.go. the final log appears to be due to a select on the repository table and is probably this line:

if _, err := x.Get(repo); err != nil {

Which probably shouldn't be x.Get but rather be sess.Get

@KubqoA
Copy link
Contributor Author

KubqoA commented Jan 25, 2019

So the issue is in that migration file?

@typeless
Copy link
Contributor

It is the exact line @zeripath demonstrated.

@KubqoA
Copy link
Contributor Author

KubqoA commented Jan 25, 2019

So should I create a pull request so this can get fixed?

@zeripath
Copy link
Contributor

Yup. You're hitting an SQL deadlock in the v67 migration.

I recently did a check up of the rest of the codebase looking for deadlocks but skipped the migrations coz I assumed incorrectly that these would have been caught already. Clearly I need to check them aswell.

In your case this should be a very easy fix - although I won't be able to make a PR for several hours possibly not till Saturday so if someone else could do it I can lgtm it. The simplest way to prevent deadlocks is to ensure that all dependent db queries are done within the same transaction.

(You can be a bit cleverer but it will almost always bite you later.)

@typeless
Copy link
Contributor

@KubqoA That would be nice 😄

@KubqoA
Copy link
Contributor Author

KubqoA commented Jan 25, 2019

Created the pull request @zeripath

@NetOpWibby
Copy link

Is this why upgrading to 1.7.0 isn't working?

@zeripath
Copy link
Contributor

zeripath commented Jan 26, 2019

@NetOperatorWibby without more information from you I couldn't possibly comment

@zeripath zeripath changed the title Failed migration causes Gitea to not start Failed migration v67 remove stale watches causes Gitea to not start Jan 26, 2019
@lafriks lafriks added type/bug and removed in progress type/question Issue needs no code to be fixed, only a description on how to fix it yourself. labels Jan 27, 2019
@lafriks lafriks added this to the 1.7.1 milestone Jan 27, 2019
bmackinney pushed a commit to bmackinney/gitea that referenced this issue Jan 27, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants