You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the need for nested transactions and have already implemented a simple but working solution. I would like to bring this to your attention and double check if this is the desired behavior or not.
Imagine an API handler needs to ensure that an operation across two different BMCs is transactional.
pubasyncfnsome_api_handler(State(mm):State<ModelManager>) -> Result<()>{let mm = mm.new_with_txn()?;
mm.dbx().begin_txn().await?;FooBmc::create(&mm,&foo_payload).await?;BarBmc::create(&mm,&bar_payload).await?;
mm.dbx().commit_txn().await?;Ok(())}
However, BarBmc needs to make sure that it's create function is always in a transaction, regardless of whether the calling site already has a running transaction or not.
I have the need for nested transactions and have already implemented a simple but working solution. I would like to bring this to your attention and double check if this is the desired behavior or not.
Imagine an API handler needs to ensure that an operation across two different BMCs is transactional.
However,
BarBmc
needs to make sure that it'screate
function is always in a transaction, regardless of whether the calling site already has a running transaction or not.If you call
BarBmc::create
without a transaction, everything will work.If you call
BarBmc::create
inside a running transaction, you get a(code: 5) database is locked error
(probably only in SQLite).A simple solution would be that
mm.new_with_transaction()
should not reset thetxn_holder
.Let me know what you think.
The text was updated successfully, but these errors were encountered: