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

Remove redundant call to UpdateRepoStats during migration (#18591) #18794

Merged

Conversation

singuliere
Copy link
Contributor

@singuliere singuliere commented Feb 17, 2022

This backport of #18591 is required because the migration will fail if there are no pull request in the migrated project. A workaround is to create a pull request until this backport lands.

From the bug report in the chat room:

2022/02/17 09:44:01 ...ices/task/migrate.go:47:func1() [C] PANIC during runMigrateTask[6] by DoerID[1] to RepoID[6] for OwnerID[1]: runtime error: index out of range [0] with length 0

    Stacktrace: /usr/local/go/src/runtime/panic.go:90 (0x43b334)

    /go/src/code.gitea.io/gitea/models/migrate.go:151 (0x123d897)

    /go/src/code.gitea.io/gitea/services/migrations/gitea_uploader.go:586 (0x1c63178)

    /go/src/code.gitea.io/gitea/services/migrations/migrate.go:376 (0x1c78395)

    /go/src/code.gitea.io/gitea/services/migrations/migrate.go:129 (0x1c76d39)

    /go/src/code.gitea.io/gitea/services/task/migrate.go:112 (0x1d1f1b5)

    /go/src/code.gitea.io/gitea/services/task/task.go:33 (0x1d20044)

    /go/src/code.gitea.io/gitea/services/task/task.go:55 (0x1d2030f)

    /go/src/code.gitea.io/gitea/modules/queue/workerpool.go:416 (0x14a0da2)

    /go/src/code.gitea.io/gitea/modules/queue/workerpool.go:266 (0x149ff56)

    /usr/local/go/src/runtime/asm_amd64.s:1581 (0x471e40)

…8591)

There is no need to call UpdateRepoStats in the InsertIssues and
InsertPullRequests function. They are only called during migration by
the CreateIssues and CreateReviews methods of the gitea uploader.

The UpdateRepoStats function will be called by the Finish method of
the gitea uploader after all reviews and issues are inserted. Calling
it before is therefore redundant and the associated SQL requests are
not cheap.

The statistics tests done after inserting an issue or a pull request
are also removed. They predate the implementation of UpdateRepoStats,
back when the calculation of the statistics was an integral part of
the migration function. The UpdateRepoStats is now tested
independantly and these tests are no longer necessary.

Signed-off-by: singuliere <singuliere@autistici.org>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@singuliere singuliere added this to the 1.16.2 milestone Feb 17, 2022
@singuliere singuliere added type/bug topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them labels Feb 17, 2022
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 17, 2022
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 17, 2022
@zeripath zeripath merged commit 458239b into go-gitea:release/v1.16 Feb 17, 2022
@zeripath zeripath changed the title remove redundant call to UpdateRepoStats during migration (#18591) Remove redundant call to UpdateRepoStats during migration (#18591) Feb 21, 2022
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants