-
Notifications
You must be signed in to change notification settings - Fork 8
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
Investigate alternative transaction API #2765
Comments
The DAL's aren't designed to be shared at all, the current situation is temporary while all the service refactoring is occurring. The correct way to share is to share the underlying queries. I do agree it's easy to use a DAL method outside a transaction though, but that can be fixed with a relatively straightforward change to the API - make the DAL something like: type DAL struct {}
func (d *DAL) Begin(ctx context.context) *Tx { ... } With all of the current DAL methods moved to Tx. |
So you don't think we will have a situation where we want a TX that encompasses operations for different parts of the code base? I am thinking about things like starting pub/sub or adding cron entries. If we can't do these things transactionally we could end up in a position where a deployment is 'half deployed', with some stuff commited to the database even though other parts have failed. |
We definitely do, but that's what I was referring to when I was talking about sharing queries, eg. for the cron service we reuse the async SQL queries. The DAL's shouldn't be treated as part of the public interface of these subsystems, as they're internal implementation details. Also at some point they likely won't be part of the same database (eg. if cron becomes a "system" module), so sharing transactions won't be possible. Keeping them isolated will help with that refactoring. |
In that case I will close this. |
The current transaction API has a couple of limitations / issues:
I think we should investigate adding the transaction to the Context, and then all subsequent DB accesses using this Context would use the same transaction. This would allow the transaction to be propagated between DALs, and mean't that you can't accidentally do work outside the transaction.
The text was updated successfully, but these errors were encountered: