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
The weird part is it is really occasionally. If I fresh my db and runs the phpunit tests, it get the error in just couple tests cases involving the transition. I have more than 10 tests involving this transition and sometimes the issue happens in different test cases, what makes me think about some kind of concurrency but I'm not using jobs or queue for this process (it has been used in a rest endpoint). Other weird fact: when I run all the tests individually, all them are passed.
When I removes the nested transition the issues didn't happen (or I didn't face it at least):
// foreach ($this->order->items as $item) {
// $item->state->transitionTo(Confirmed::class); // here is my "nested" transition.
// }
The transition of items to Confirmed has some dependencies but nothing too big, just some internal fields updated and I created a row in a history table to "save" the history of transitions.
Exists inside the package any kind of thing that can brings me some explanation? Some operation each fires an implicit commit?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a project where we are using states for the model
SalesOrder
andSalesOrderItem
(the items have a internal state too).When I do an transition of a
SalesOrder
model, I call the transition for all the attached items (SalesOrderItem
) too:Every think is working fine in my firsts tests.
At some point I added the routine to execute the transition inside a
DB::transaction()
and my issue started.Occasionally I get the error
There is no active transaction
.I'm already warned about implicit commits (https://laravel.com/docs/9.x/database#implicit-commits-in-transactions) but I didn't see anything that can fire one, I just fire this transition inside the transaction.
The weird part is it is really occasionally. If I fresh my db and runs the phpunit tests, it get the error in just couple tests cases involving the transition. I have more than 10 tests involving this transition and sometimes the issue happens in different test cases, what makes me think about some kind of concurrency but I'm not using jobs or queue for this process (it has been used in a rest endpoint). Other weird fact: when I run all the tests individually, all them are passed.
When I removes the nested transition the issues didn't happen (or I didn't face it at least):
The transition of items to
Confirmed
has some dependencies but nothing too big, just some internal fields updated and I created a row in a history table to "save" the history of transitions.Exists inside the package any kind of thing that can brings me some explanation? Some operation each fires an implicit commit?
Beta Was this translation helpful? Give feedback.
All reactions