Is there a way in Django to unlock the resources before the transaction is over or to auto restart the transaction if the deadlock is found? #8012
Unanswered
jeetpatel9
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am not sure if this the right place to ask this question.
I have a model
Orders
in my Django rest-framework app. I am retrieving a list of orders based on some filter parameters and at the same time I am also locking orders usingselect_for_update()
.Each order in the
Orders
model has astatus
and it could beOPEN
,PARTIALLY_COMPLETED
,COMPLETED
orCANCELLED
. However, one of my filter parameters will only consider the order with statusOPEN
orPARTIALLY_COMPLETED
. So the retrieved list will have order withOPEN
orPARTIALLY_COMPLETED
status only.Furthermore, each order in
Orders
model also has the parameterunits
. This represents theunits
at which the order was created. If the order is inOPEN
state then all the units are unsold or if the order is inPARTIALLY_COMPLETED
thenunsold_units = units - sold_units
. Deriving the unsold units forPARTIALLY_COMPLETED
orders is done after retrieving the list of orders.Now, let's assume the retrieved order list has 10 order and the total of
unsold_units
of the list is 1000. However, I just need 100 units so if theunsold_units
of the first3
orders is equal or over 100 units than the remaining orders must be unlocked immediately so that the other transaction can use it.Is there a way in Django to unlock the resources before the transaction is over?
Is there a way to auto restart the transaction if the deadlock is found?
Beta Was this translation helpful? Give feedback.
All reactions