-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
|
Co-authored-by: delvh <dev.lh@web.de>
tip use |
@wxiaoguang I did the merge into a db.WithTx() ... so the scope of the transaction now should be clear :) |
There was a problem hiding this 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.
@6543 do you have plan to use If yes, let's wait for the change. |
it has to do something with how notification package is handled
next deadlock: |
…e merge infoce internal api that cant handle open db sessions to the same repo
🚀 |
-> #19596 ... |
* 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)
... more context (part of go-gitea#9307)
@@ -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() |
There was a problem hiding this comment.
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()!
// TODO: this cause an api call to "/api/internal/hook/post-receive/...", | ||
// that prevents us from doint the whole merge in one db transaction |
There was a problem hiding this comment.
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
... more context
(part of #9307)