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

Make sure if a DB Session got created for a request, it stays unique per request #19513

Closed
1 of 3 tasks
6543 opened this issue Apr 26, 2022 · 0 comments · Fixed by #20031 or #21756
Closed
1 of 3 tasks

Make sure if a DB Session got created for a request, it stays unique per request #19513

6543 opened this issue Apr 26, 2022 · 0 comments · Fixed by #20031 or #21756
Labels
type/summary This issue aggregates a bunch of other issues
Milestone

Comments

@6543
Copy link
Member

6543 commented Apr 26, 2022

to prevent deadlocks, etc...:

  • use context for all function calling package model and model itself
  • add func that can extract an open session from context if there is one or open a new one
  • be able to make sure, if db.TxContext() was already opened, a function within the stack does not open a second one again
@6543 6543 added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/summary This issue aggregates a bunch of other issues labels Apr 26, 2022
@6543 6543 added this to the 1.17.0 milestone Apr 26, 2022
@lunny lunny modified the milestones: 1.17.0, 1.18.0 May 16, 2022
@6543 6543 reopened this Jun 20, 2022
@lunny lunny modified the milestones: 1.18.0, 1.19.0 Oct 17, 2022
@lunny lunny removed the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Nov 10, 2022
6543 added a commit that referenced this issue Nov 12, 2022
…text (#21756)

Fix #19513

This PR introduce a new db method `InTransaction(context.Context)`,
and also builtin check on `db.TxContext` and `db.WithTx`.
There is also a new method `db.AutoTx` has been introduced but could be used by other PRs.

`WithTx` will always open a new transaction, if a transaction exist in context, return an error.
`AutoTx` will try to open a new transaction if no transaction exist in context.
That means it will always enter a transaction if there is no error.

Co-authored-by: delvh <[email protected]>
Co-authored-by: 6543 <[email protected]>
@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
type/summary This issue aggregates a bunch of other issues
Projects
None yet
2 participants