fix(migration): panic when ExecuteMigration
fails
#8070
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pr-type/bug-fix
,pr-type/feature-development
, etc.Summary
What does this PR do?
Panic when
ExecuteMigration
fails.Why?
ExecuteMigration
is regared as a function that will succeed always, because if it return an error, backend will panic directly.What problems can be solved?
In these code:
ExecuteMigration
will return an error and the main program will go on.If there is a new migration script which will return an error when executing , user will have to process db migration.
When this API is called, it returns an error.
But errors are different.
The frist time, it will return from https://github.com/apache/incubator-devlake/blob/main/backend/server/services/init.go#L157.
The second and following times, it will return from https://github.com/apache/incubator-devlake/blob/main/backend/server/services/init.go#L146.
Users can never handle this expect for a reboot.
I think it's unreasonable and this PR just try to fix this.
Does this close any open issues?
There are some related issues #8018 #7992 , but this fix is not the root cause of them.
Screenshots
Include any relevant screenshots here.
It will not return
There is a migration in progress.
The backend will panic and recover(by gin framework if it's in release mode) directly.Other Information
Any other information that is important to this PR.