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

Use for a repo action one database transaction #19576

Merged
merged 17 commits into from
May 3, 2022

Conversation

6543
Copy link
Member

@6543 6543 commented May 2, 2022

... more context

(part of #9307)

@6543 6543 added pr/wip This PR is not ready for review type/refactoring Existing code has been cleaned up. There should be no new functionality. labels May 2, 2022
@6543 6543 added this to the 1.17.0 milestone May 2, 2022
routers/api/v1/repo/pull.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 2, 2022
routers/web/repo/pull.go Outdated Show resolved Hide resolved
routers/api/v1/repo/pull.go Outdated Show resolved Hide resolved
routers/api/v1/repo/pull.go Outdated Show resolved Hide resolved
services/issue/status.go Outdated Show resolved Hide resolved
@6543
Copy link
Member Author

6543 commented May 2, 2022

TestAPIBranchProtection -> delete branch has a deadlock :/ ... need more infestigation (that's why its wip)

@6543
Copy link
Member Author

6543 commented May 3, 2022

tip use https://github.com/go-gitea/gitea/pull/19576/files?diff=unified&w=1 to have a clue what has changed :)

@6543
Copy link
Member Author

6543 commented May 3, 2022

@wxiaoguang I did the merge into a db.WithTx() ... so the scope of the transaction now should be clear :)

@6543 6543 removed the pr/wip This PR is not ready for review label May 3, 2022
@6543 6543 requested review from wxiaoguang and lunny May 3, 2022 17:42
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

It seems that err = db.WithTx(...); if err != nil {} could be easier to read than if db.WithTx(....) != nil { } when the func code are very long.

@GiteaBot GiteaBot 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 3, 2022
@GiteaBot GiteaBot removed the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label May 3, 2022
@GiteaBot GiteaBot added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label May 3, 2022
@wxiaoguang
Copy link
Contributor

@6543 do you have plan to use err = db.WithTx(...); if err != nil {} to replace if db.WithTx(....) != nil { } before merge?

If yes, let's wait for the change.

@6543
Copy link
Member Author

6543 commented May 3, 2022

95df0f2 -> as per @lunny (via DM)

it has to do something with how notification package is handled
@6543
Copy link
Member Author

6543 commented May 3, 2022

next deadlock: TestGit/HTTP/CreateAgitFlowPull ...

…e merge infoce internal api that cant handle open db sessions to the same repo
@6543
Copy link
Member Author

6543 commented May 3, 2022

🚀

@6543 6543 merged commit 92f139d into go-gitea:main May 3, 2022
@6543 6543 deleted the more-context-again branch May 3, 2022 19:46
@6543
Copy link
Member Author

6543 commented May 3, 2022

-> #19596 ...

zjjhot added a commit to zjjhot/gitea that referenced this pull request May 4, 2022
* giteaofficial/main:
  Fix broken TR on cherrypick page (go-gitea#19599)
  Use correct context in `routers/web` (go-gitea#19597)
  Use for a repo action one database transaction (go-gitea#19576)
  Only set CanColorStdout / CanColorStderr to true if the stdout/stderr is a terminal (go-gitea#19581)
  Don't fetch Mirror when it's migrating (go-gitea#19588)
  Move user password verification after checking his groups on ldap auth (go-gitea#19587)
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
@@ -59,7 +60,9 @@ func Merge(ctx context.Context, pr *models.PullRequest, doer *user_model.User, b
go AddTestPullRequestTask(doer, pr.BaseRepo.ID, pr.BaseBranch, false, "", "")
}()

pr.MergedCommitID, err = rawMerge(ctx, pr, doer, mergeStyle, expectedHeadCommitID, message)
// TODO: make it able to do this in a database session
mergeCtx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should NEVER use context.Background()!

Comment on lines +509 to +510
// TODO: this cause an api call to "/api/internal/hook/post-receive/...",
// that prevents us from doint the whole merge in one db transaction
Copy link
Contributor

Choose a reason for hiding this comment

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

If you know that you don't want our hooks to run you could have used the InternalPushingEnvironment

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
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/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants