mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-19 02:14:34 -05:00
ORM issue upgrading from 1.13.7 to 1.14.3 on error 500 repo #7513
Closed
opened 2025-11-02 07:28:10 -06:00 by GiteaMirror
·
22 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.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c2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#7513
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Jack64 on GitHub (Jun 27, 2021).
[x]):Description
When trying to upgrade from 1.13.7 to 1.14.0, I get an ORM initialization error as shown in the logs above. It is unclear which repository is causing this, please help.
EDIT: added log line below to help others facing this problem find this issue
@zeripath commented on GitHub (Jun 27, 2021):
Please try 1.14.3 - it will at least give you more information even if it continues to fail.
In general once a point release is release just use the latest point release - never use the lower point releases unless absolutely necessary.
@zeripath commented on GitHub (Jun 27, 2021):
I just don't understand why you would ever not just use the latest point release? How can we improve our documentation so people don't do this?
I'm serious here - we fix a large number of bugs in between point releases - sometimes with migrations - sometimes bugs that would cause data loss. If you use the lowest point release instead of jumping to the latest point release you're exposing yourself to already fixed bugs and wasting our time responding to bug reports that are duplicates.
@Jack64 commented on GitHub (Jun 27, 2021):
@zeripath I wasn't actually planning on staying at 1.14.0. I moved from 1.13.1 to 1.13.7 prior to upgrading to 1.14.0, assuming this would improve my chances of a successful minor release upgrade. If I understand correctly, you are recommending that if someone is at 1.X."latest-patch" they should upgrade directly to 1.Y."latest-patch" ?
In any case, this produces the same result, curiously on a mirror of gitea itself:
@Jack64 commented on GitHub (Jun 27, 2021):
Do you have any suggestions for a next step? I can always remove the mirror while on 1.13.7 and try again, but what if this happens on a repo I can't remove?
@zeripath commented on GitHub (Jun 27, 2021):
Yes always go from latest point release to latest point release.
Anyway this is a duplicate issue. The error message on 1.14.3 is different if you read the logs:
The migration can't find the repository in the place it is looking for. That is likely because your
[repository]ROOTis incorrect - likely you left it unset in your app.ini but unfortunately we had to change this default location because of snap.The breaking notes for 1.14 state:
Likely all you have to do is set
[repository]ROOTcorrectly or move them to the new location.See: #16217 and #16210
@Jack64 commented on GitHub (Jun 27, 2021):
OK in the future I'll remember to upgrade minor versions from latest point release to latest point release.
I have the [repository] ROOT set in the app.ini but it fails regardless. I have no other keys set under [repository] and I don't have [server] APP_DATA_PATH defined.
I'm using "/data/git/gitea-repositories" as [repository]ROOT, from what I gathered from the other issues I need to move it to something like "/data/gitea/git/gitea-repositories" and also set [server]APP_DATA_PATH = /data/gitea so that [repository]ROOT becomes a subdirectory of APP_DATA_PATH. Is this correct?
@zeripath commented on GitHub (Jun 27, 2021):
What command are you running? Are you running that command in the same environment as you would normally run Gitea and with the same arguments?
@Jack64 commented on GitHub (Jun 27, 2021):
Yes, nothing has changed in that regard. I'm simply running the Docker container pointing to the app.ini I'm mounting in there.
The thing is, I have a terraform module that I use to run gitea which allows automatic periodic backups and restores from a minio / S3 bucket so since I was moving it from one Kubernetes cluster to another, it ran in migration mode and had to pull all the data from the S3 to put it in the correct folder (i.e. [repository]ROOT). This has worked flawlessly since (IIRC) 1.11 . If [repository]ROOT now must be a subdir of APP_DATA_PATH (which I have not set), I have to change the backup/restore scripts to adjust to this change.
@zeripath commented on GitHub (Jun 27, 2021):
it doesn't have to be - you can set it anywhere.
If you're absolutely certain that you have
[repository]ROOTset and that you're reading in the config correctly - then the problem is going to be that the repository this migration is looking for simply doesn't exist.So ... are you sure that
$ROOT/mirrors/gitea.gitis a bare git repository ?@zeripath commented on GitHub (Jun 27, 2021):
No. So long as you have set the ROOT to an absolute path the APP_DATA_PATH is irrelevant regarding this.
@Jack64 commented on GitHub (Jun 27, 2021):
Good hint. It shows in the repo search but then it throws a 500 error when I try to access it (on 1.13.7).

I don't see any error logs anywhere to explain this 500 error.
@zeripath commented on GitHub (Jun 27, 2021):
Likely it's not there and you just need to remove it from the db. Probably there was a migration failure at some point and the repository wasn't properly removed - 1.14.x won't do that.
you might be able to use an url like
http://gitea/mirors/gitea/settingsto get to the settings page directly and delete the repository that way if you don't know how to remove it directly from the db.@Jack64 commented on GitHub (Jun 27, 2021):
Yes that's likely.
Unfortunately /settings throws an error as well. I guess all that's left is removing it from the DB directly, do you by any chance have the SQL command at hand ? I see that I have other repos in this situation so I'll have to do it more than once ..
@zeripath commented on GitHub (Jun 27, 2021):
DELETE FROM repository WHERE owner_name = 'mirrors' AND name = 'gitea'@zeripath commented on GitHub (Jun 27, 2021):
normally we'd just have the migrations delete these sort of things but as the ROOT location can be wrong it's not really the right thing to do in this case.
@zeripath commented on GitHub (Jun 27, 2021):
An alternate option is to just do a
git init --bare owner/repo.gitin your$ROOTas that should allow stop the 500.@Jack64 commented on GitHub (Jun 27, 2021):
Yes I realized that might be why it's not "auto-fixed". Would be nice to have somewhere in the UI (administration section maybe?) where we could do this without having to jump into the SQL, though. But perhaps it's not that common an issue to make this a priority.
The DELETE command worked flawlessly, thank you very much. I'll re-run the migration now and delete any other repos in this situation.
@Jack64 commented on GitHub (Jun 27, 2021):
Boom - 1.14.3 running 👍 thanks again for your invaluable help @zeripath , this sort of incredibly fast and helpful support puts some commercial solutions to shame!! 🙏 🙏
@zeripath commented on GitHub (Jun 27, 2021):
Trouble is to get to any fixed UI would require you to pass the migration step first...
The other issue is that the loss of a repo should cause a 500 - it is an internal server error. I'm not sure I really want these to be tolerated. Something has gone drastically wrong if the git repo has disappeared - but yeah it's not great that then you're stuck in a broken db situation even if the rest of the situation is resolvable.
@zeripath commented on GitHub (Jun 27, 2021):
I'll close this and think a bit more about the 500 issue.
@Jack64 commented on GitHub (Jun 27, 2021):
The common solution for this is simply rolling-back to the last working version (in my case 1.13.7). After that, I would be able to go to the Administration panel and see that there is an "errored repo". If I had a list of such repos there, I could manually decide which ones could be safely deleted (pressing a button that ran this DELETE SQL command on the back-end) or leave it alone in order to restore the data, depending on which case it were.
At least that's how I imagined this would work. By putting this on the Administration tab and not on the repo settings it'd bypass the 500 error.
Fully agree here that there shouldn't be an "auto-fix", because it may use the "wrong fix" by deleting or keeping it. The point of that UI would be to point out to the admin that there are repos in this situation (fortunately for me it was only this mirror + my own fork of it) and allow them to fix it. I'm not sure if this is common enough to warrant the new UI, but if this happened by a rogue rm -rf or ransomware or something, it'd be invisible if it's not a regularly used repo (which was the case).
EDIT: Another thing to consider is the improved verbosity of the logs on 1.14.3 now allow a relatively quick diagnosis, so having to do this SQL command once in 3 years of running Gitea and using it every day didn't "kill me" and shouldn't be that big a deal for anyone else (aside from the effort of actually knowing the right command to run).
@Jack64 commented on GitHub (Jun 27, 2021):
updated the title, might help anyone with this exact problem find this issue.