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

Retry rename on lock induced failures (#16435) #16439

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

zeripath
Copy link
Contributor

Backport #16435

Due to external locking on Windows it is possible for an
os.Rename to fail if the files or directories are being
used elsewhere.

This PR simply suggests retrying the rename again similar
to how we handle the os.Remove problems.

Fix #16427

Signed-off-by: Andrew Thornton art27@cantab.net
Co-authored-by: techknowlogick techknowlogick@gitea.io

Backport go-gitea#16435

Due to external locking on Windows it is possible for an
os.Rename to fail if the files or directories are being
used elsewhere.

This PR simply suggests retrying the rename again similar
to how we handle the os.Remove problems.

Fix go-gitea#16427

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@zeripath zeripath added this to the 1.14.5 milestone Jul 15, 2021
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jul 15, 2021
@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 Jul 15, 2021
@lafriks lafriks merged commit ca55e49 into go-gitea:release/v1.14 Jul 15, 2021
@zeripath zeripath deleted the backport-16435-v1.14 branch July 15, 2021 19:58
@onlygecko
Copy link

onlygecko commented Jul 16, 2021

The 1.14.5 does not solve the issue. But there is now a different error message:

2021/07/16 14:02:49 ...uters/routes/base.go:153:1() [E] PANIC: interface conversion: error is *os.LinkError, not *fs.PathError
	/usr/local/go/src/runtime/iface.go:261 (0x10bcf8c)
	/usr/local/go/src/runtime/iface.go:271 (0x10bcef6)
	/source/modules/util/remove.go:67 (0x14becdb)
	/source/models/repo.go:1218 (0x2197a7c)
	/source/services/repository/transfer.go:63 (0x2d2547e)
	/source/routers/repo/setting.go:80 (0x2e1c192)
	/source/modules/web/route.go:64 (0x2ca2ffb)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/mux.go:436 (0x284c5ea)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/web/route.go:103 (0x2ca36e9)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/web/route.go:103 (0x2ca36e9)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/web/route.go:103 (0x2ca36e9)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/web/route.go:103 (0x2ca36e9)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/middleware/get_head.go:37 (0x2ed4ea1)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/context/context.go:704 (0x286c121)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/base.go:87 (0x2edc44e)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/base.go:87 (0x2edc44e)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/public/public.go:86 (0x20d8fec)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/modules/public/public.go:86 (0x20d8fec)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/base.go:199 (0x2ede1d7)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/gitea.com/go-chi/session/session.go:256 (0x222f90e)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/mux.go:70 (0x284a0ea)
	/source/vendor/github.com/go-chi/chi/mux.go:311 (0x285059b)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/mux.go:436 (0x284c5ea)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/web.go:107 (0x2edf664)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/base.go:38 (0x2edb1c8)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/middleware/strip.go:30 (0x2ed57e7)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/chi-middleware/proxy/middleware.go:37 (0x2ed0d13)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/routers/routes/web.go:63 (0x2edf1a7)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/source/vendor/github.com/go-chi/chi/mux.go:87 (0x2849e70)
	/source/modules/web/route.go:298 (0x2ca251a)
	/source/vendor/github.com/gorilla/context/context.go:141 (0x1e990da)
	/usr/local/go/src/net/http/server.go:2049 (0x1485e0a)
	/usr/local/go/src/net/http/server.go:2867 (0x1489449)
	/usr/local/go/src/net/http/server.go:1932 (0x14848cc)
	/usr/local/go/src/runtime/asm_amd64.s:1371 (0x1126640)
	
2021/07/16 14:02:49 ...les/public/public.go:165:handle() [I] [Static] Serving /img/500.png

@zeripath
Copy link
Contributor Author

This is why I asked you people to test this.

if err == nil {
break
}
unwrapped := err.(*os.PathError).Err
Copy link
Contributor Author

@zeripath zeripath Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be:

Suggested change
unwrapped := err.(*os.PathError).Err
unwrapped := err.(*os.LinkError).Err

zeripath added a commit to zeripath/gitea that referenced this pull request Jul 16, 2021
Unfortunately go-gitea#16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix go-gitea#16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this pull request Jul 16, 2021
Backport go-gitea#16461

Unfortunately go-gitea#16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix go-gitea#16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this pull request Jul 16, 2021
Backport go-gitea#16461

Unfortunately go-gitea#16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix go-gitea#16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

@onlygecko for the avoidance of future problems could you please test #16463?

https://www.eldritchkitty.com/~andrew/gitea-1.14.5-16463-windows-4.0-amd64.exe is a windows build of 1.14 with #16463 compiled in. (Once it uploads to my server of course.)

https://www.eldritchkitty.com/~andrew/gitea-1.14.5-16463-windows-4.0-amd64.exe.asc is the gpg signature signed by my key if you want to assert that this from me.

zeripath added a commit that referenced this pull request Jul 16, 2021
Backport #16461

Unfortunately #16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix #16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
6543 pushed a commit that referenced this pull request Jul 16, 2021
Unfortunately #16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix #16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
techknowlogick pushed a commit that referenced this pull request Jul 16, 2021
Backport #16461

Unfortunately #16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix #16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
@onlygecko
Copy link

onlygecko commented Jul 17, 2021 via email

@zeripath
Copy link
Contributor Author

Unfortunately this doesn't appear to be enough... So let's try #16481 instead:

https://www.eldritchkitty.com/~andrew/gitea-1.14.5-16481-windows-4.0-amd64.zip

which contains a build of 1.14 with the above PR and it's gpg signature.

AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 10, 2021
Unfortunately go-gitea#16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix go-gitea#16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
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. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants