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

Fix deadlock in updateRepository #1813

Merged
merged 1 commit into from
May 26, 2017
Merged

Conversation

ethantkoenig
Copy link
Member

Fix a potential deadlock in updateRepository(). The call to UpdateSize() previously did not use the provided session (i.e. the e parameter), and the resulting query could become blocked by the ongoing session/transaction, since both the query and the ongoing transaction need to access the repository table.

I experienced this deadlock locally, using PostgreSQL.

@sapk
Copy link
Member

sapk commented May 26, 2017

repo.UpdateSize is used in others places : like

if err := m.Repo.UpdateSize(); err != nil {
or
if err = repo.UpdateSize(); err != nil {

Edit: Sorry, I missed some code part.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 26, 2017
@sapk
Copy link
Member

sapk commented May 26, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 26, 2017
@lunny lunny added this to the 1.2.0 milestone May 26, 2017
@lunny lunny added the type/bug label May 26, 2017
repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
if err != nil {
return fmt.Errorf("UpdateSize: %v", err)
}

repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
_, err = x.ID(repo.ID).Cols("size").Update(repo)
_, err = e.Id(repo.ID).Cols("size").Update(repo)
Copy link
Member

Choose a reason for hiding this comment

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

ID is better than Id

Copy link
Member Author

Choose a reason for hiding this comment

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

ID is not in the Engine interface.

Copy link
Member

Choose a reason for hiding this comment

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

OK. Let's do that later!

@lunny
Copy link
Member

lunny commented May 26, 2017

A small change required, otherwise LGTM

@tboerger tboerger 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 May 26, 2017
@lunny lunny merged commit 9c66d1d into go-gitea:master May 26, 2017
@ethantkoenig ethantkoenig deleted the fix_update_repo branch May 27, 2017 03:03
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
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.

4 participants