Migration from GitHub fails with Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction #1323

Open
opened 2023-10-25 19:43:25 +02:00 by VadZ · 22 comments

Comment

I tried to migrate a (rather big) https://github.com/wxWidgets/wxWidgets.git repository from GitHub for testing it on Codeberg but migration unfortunately failed with the error message in the subject (there are no further details).

I used a token for migration, if it matters, and I didn't delete the repository just in case there could be something useful for diagnosing this issue in it.

### Comment I tried to migrate a (rather big) https://github.com/wxWidgets/wxWidgets.git repository from GitHub for testing it on Codeberg but migration unfortunately failed with the error message in the subject (there are no further details). I used a token for migration, if it matters, and I didn't delete the repository just in case there could be something useful for diagnosing this issue in it.

@VadZ I cannot support technically but wanted to contribute that I am happy to hear you consider migrating this interesting and busy (75k+ commits and counting) repository to code berg. Welcome!

@VadZ I cannot support technically but wanted to contribute that I am happy to hear you consider migrating this interesting and busy (75k+ commits and counting) repository to code berg. Welcome!
Author

To be perfectly honest, this was just the first exploratory step, we don't have any concrete plans for migrating from GitHub yet, but I'd like to have a solution if this turns out to be necessary.

To be perfectly honest, this was just the first exploratory step, we don't have any concrete plans for migrating from GitHub yet, but I'd like to have a solution if this turns out to be necessary.

My bad, I used the wrong word "migrating" (I guess because most services suggest that).

What I really meant was more like "porting".

My bad, I used the wrong word "migrating" (I guess because most services suggest that). What I really meant was more like "porting".
Owner

This is very likely related to forgejo/forgejo#220

We fixed a number of deadlocks in the past and for others we improved performance and optimized queries to reduce the chances that they occur. I am currently not aware of any other deadlocks that occur often or persist, but this one could be.

@VadZ I recommend that you retry the migration once, avoiding the rush hour during european evenings (16 - 23 CEST). If it still fails, we'll have a closer look. Please give us a precise timestamp.

This is very likely related to https://codeberg.org/forgejo/forgejo/issues/220 We fixed a number of deadlocks in the past and for others we improved performance and optimized queries to reduce the chances that they occur. I am currently not aware of any other deadlocks that occur often or persist, but this one could be. @VadZ I recommend that you retry the migration once, avoiding the rush hour during european evenings (16 - 23 CEST). If it still fails, we'll have a closer look. Please give us a precise timestamp.
Author

Thanks, do you mean to give the time when I'll start the migration in advance or the time when it happens? I could try launching the migration again this night (2-3 CEST), but I wouldn't necessarily know when exactly it stops.

Thanks, do you mean to give the time when I'll start the migration in advance or the time when it happens? I could try launching the migration again this night (2-3 CEST), but I wouldn't necessarily know when exactly it stops.
Owner

Try to tell us afterwards. We can search a little bit in the logs, but the more precise the better.

Try to tell us afterwards. We can search a little bit in the logs, but the more precise the better.
Author

Sorry, no precise time stamp because it was taking too long and I logged off, but after retrying the migration last night, it ended with

PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1

this time.

Sorry, no precise time stamp because it was taking too long and I logged off, but after retrying the migration last night, it ended with > PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1 this time.
Owner

Relevant log output:

/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: object does not exist [id: 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, rel_path: ]
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - 
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - 
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - 
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "<mail@jensgoepfert.de> 1542805549 +0100": invalid syntax
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "<mail@jensgoepfert.de> 1542805549 +0100": invalid syntax
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "GetLineAt keeps unsigned int": invalid syntax
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ices/task/migrate.go:47:func1() [E] PANIC during runMigrateTask[28366] by DoerID[104903] to RepoID[156486] for OwnerID[104903]: runtime error: index out of range [1] with length 1
/data/git/log/gitea.log.2023-10-27.003.gz-Stacktrace: /home/build/build-deploy-forgejo/build/go-1.20.10/go/src/runtime/panic.go:113 (0x44203e)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/git/diff.go:99 (0xd504f1)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/gitea_uploader.go:865 (0x22cffcf)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/migrate.go:445 (0x22e4c73)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/migrate.go:130 (0x22e2d9c)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/migrate.go:124 (0x25edca4)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/task.go:32 (0x25eebe4)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/task.go:50 (0x25eee8d)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workerqueue.go:246 (0x1cb119c)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workergroup.go:98 (0x1cb398d)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workergroup.go:162 (0x1cb0ba8)
/data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/go-1.20.10/go/src/runtime/asm_amd64.s:1598 (0x47ba80)
/data/git/log/gitea.log.2023-10-27.003.gz:2023/10/27 07:46:06 ...ices/task/migrate.go:60:func1() [E] runMigrateTask[28366] by DoerID[104903] to RepoID[156486] for OwnerID[104903] failed: PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: signal: killed - 
/data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: signal: killed - 
/data/git/log/gitea.log.2023-10-27.003.gz:2023/10/27 07:46:06 ...ervices/task/task.go:51:handler() [E] Run task failed: PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1

Not sure what to take out of this. Did it simply timeout?

Relevant log output: ~~~ /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: object does not exist [id: 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, rel_path: ] /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: io: read/write on closed pipe - /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "<mail@jensgoepfert.de> 1542805549 +0100": invalid syntax /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "<mail@jensgoepfert.de> 1542805549 +0100": invalid syntax /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, bdca91c629c752bb733490dbb317c590646c4120, 50e86881c9da270ea5d16390dcb53ffb5bebf5e8, include/wx/private/smartrowheightcache.h]: strconv.ParseInt: parsing "GetLineAt keeps unsigned int": invalid syntax /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ices/task/migrate.go:47:func1() [E] PANIC during runMigrateTask[28366] by DoerID[104903] to RepoID[156486] for OwnerID[104903]: runtime error: index out of range [1] with length 1 /data/git/log/gitea.log.2023-10-27.003.gz-Stacktrace: /home/build/build-deploy-forgejo/build/go-1.20.10/go/src/runtime/panic.go:113 (0x44203e) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/git/diff.go:99 (0xd504f1) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/gitea_uploader.go:865 (0x22cffcf) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/migrate.go:445 (0x22e4c73) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/migrations/migrate.go:130 (0x22e2d9c) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/migrate.go:124 (0x25edca4) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/task.go:32 (0x25eebe4) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/services/task/task.go:50 (0x25eee8d) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workerqueue.go:246 (0x1cb119c) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workergroup.go:98 (0x1cb398d) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/gitea/modules/queue/workergroup.go:162 (0x1cb0ba8) /data/git/log/gitea.log.2023-10-27.003.gz-/home/build/build-deploy-forgejo/build/go-1.20.10/go/src/runtime/asm_amd64.s:1598 (0x47ba80) /data/git/log/gitea.log.2023-10-27.003.gz:2023/10/27 07:46:06 ...ices/task/migrate.go:60:func1() [E] runMigrateTask[28366] by DoerID[104903] to RepoID[156486] for OwnerID[104903] failed: PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1 /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: signal: killed - /data/git/log/gitea.log.2023-10-27.003.gz-2023/10/27 07:46:06 ...ns/gitea_uploader.go:880:func2() [W] GetRepoRawDiffForFile failed when migrating [/mnt/ceph-cluster/git/gitea-repositories/vadz/wxwidgets.git, 44b99195bc4395944bab8071c6d7adcbdcdf8773, da3117cbcc3cf311ef62d893ed48988b0d0c964c, configure.in]: Run: signal: killed - /data/git/log/gitea.log.2023-10-27.003.gz:2023/10/27 07:46:06 ...ervices/task/task.go:51:handler() [E] Run task failed: PANIC whilst trying to do migrate task: runtime error: index out of range [1] with length 1 ~~~ Not sure what to take out of this. Did it simply timeout?

I've bumped into this issue earlier today while trying to migrate a repo from Gitea (https://codeberg.org/btlogy/trac-2024-05-23-deadlock):

Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

Restarting is not possible and retrying has not helped: it either raises this error or get stuck w/o sending more request.

I only see the Go-http-client agent requesting all issues and comments from our self-hosted instance and stopping mid-migration and raising this error.

Any idea what could be blocking this?

BTW: I've managed to migrate the same repository on the latest Forgejo (here).

I've bumped into this issue earlier today while trying to migrate a repo from Gitea (https://codeberg.org/btlogy/trac-2024-05-23-deadlock): ``` Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction ``` Restarting is not possible and retrying has not helped: it either raises this error or get stuck w/o sending more request. I only see the `Go-http-client` agent requesting all issues and comments from our self-hosted instance and stopping mid-migration and raising this error. Any idea what could be blocking this? BTW: I've managed to migrate the same repository on the latest Forgejo ([here](https://v9.next.forgejo.org/btlogy/trac-2024-05-23)).
Owner

Hmm, the deadlock problem is typically a load problem on Codeberg. Some time ago we fixed quite a lot of them, but there is no guarantee that we found all the problems.

Especially with many issues it is unfortunately rather hard to migrate to Codeberg, especially during times of high load.

I recommend to retry at a time with less activity (avoiding 12 - 24 CEST). I'll try to take a closer look, too.

Hmm, the deadlock problem is typically a load problem on Codeberg. Some time ago we fixed quite a lot of them, but there is no guarantee that we found all the problems. Especially with many issues it is unfortunately rather hard to migrate to Codeberg, especially during times of high load. I recommend to retry at a time with less activity (avoiding 12 - 24 CEST). I'll try to take a closer look, too.

Thank you @fnetX : I've migrated this morning and it has worked w/o raising this error.

Thank you @fnetX : I've migrated this morning and it has worked w/o raising this error.

This is still an issue today.

This is still an issue today.

I got this error today trying to migrate from GitHub.

I got this error today trying to migrate from GitHub.

I got this error today while migrating https://codeberg.org/fsfe/reuse-tool from GitHub. I tried a few times, and then it worked.

I got this error today while migrating https://codeberg.org/fsfe/reuse-tool from GitHub. I tried a few times, and then it worked.
Owner

@carmenbianca Glad that you managed to get in here after all. We are having database deadlocks in some cases from time to time, mostly related to some cron jobs that might or might not run in parallel. We still haven't figured out what exactly causes them. Retrying some hours later usually does the trick.

@carmenbianca Glad that you managed to get in here after all. We are having database deadlocks in some cases from time to time, mostly related to some cron jobs that might or might not run in parallel. We still haven't figured out what exactly causes them. Retrying some hours later usually does the trick.

I am trying to migrate https://github.com/GCWizard/GCWizard but getting the deadlock issue as well, every time. Is there any fix right now?

Migrieren von https://github.com/GCWizard/GCWizard.git fehlgeschlagen.
Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

It always happens on step "Migrating Issues", btw

I am trying to migrate https://github.com/GCWizard/GCWizard but getting the deadlock issue as well, every time. Is there any fix right now? ``` Migrieren von https://github.com/GCWizard/GCWizard.git fehlgeschlagen. Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction ``` It always happens on step "Migrating Issues", btw

@GC-Wizard test migration (git/issues/pull requests) of your repo to a forgejo instance took me about ~2,5hrs but succeeded.

@GC-Wizard test migration (git/issues/pull requests) of your repo to a forgejo instance took me about ~2,5hrs but succeeded.

I am trying to migrate https://github.com/blackmagic-debug/blackmagic if I have anything beyond just the basic repository enabled for migration I am hitting the Deadlock issue.

Migrating from https://github.com/blackmagic-debug/blackmagic.git failed.

Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

I have now tried to migrate this repository about 4 times over the last two weeks. And still getting the Deadlock error.

Is the only advise to continue attempting migration until it succeeds? Or is there some other method to get the migration accomplished?

I am trying to migrate https://github.com/blackmagic-debug/blackmagic if I have anything beyond just the basic repository enabled for migration I am hitting the Deadlock issue. ``` Migrating from https://github.com/blackmagic-debug/blackmagic.git failed. Error 1213 (40001): Deadlock found when trying to get lock; try restarting transaction ``` I have now tried to migrate this repository about 4 times over the last two weeks. And still getting the Deadlock error. Is the only advise to continue attempting migration until it succeeds? Or is there some other method to get the migration accomplished?

Would be great if at least it kept trying on the background or in a cron. Does it?

Trying to setup a mirror from GitHub at https://codeberg.org/m0wer/joinmarket-ng

Would be great if at least it kept trying on the background or in a cron. Does it? Trying to setup a mirror from GitHub at https://codeberg.org/m0wer/joinmarket-ng

I've tried migrating https://github.com/bewcloud/bewcloud a few times already into https://codeberg.org/bewcloud/bewcloud and I keep getting that same error, unfortunately. Any suggestions?

I've tried migrating https://github.com/bewcloud/bewcloud a few times already into https://codeberg.org/bewcloud/bewcloud and I keep getting that same error, unfortunately. Any suggestions?

i have experienced this too

i have experienced this too

I have observed that, for large migrations that fail with this error, waiting till fewer users are likely using the codeberg platform (3-4 am UTC) seemed to be a strategy that helped. This seems to be an issue related to contention for database access

I have observed that, for large migrations that fail with this error, waiting till fewer users are likely using the codeberg platform (3-4 am UTC) seemed to be a strategy that helped. This seems to be an issue related to contention for database access
Sign in to join this conversation.
No milestone
No project
No assignees
12 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#1323
No description provided.