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
Ordersin 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
Ordersmodel has astatusand it could beOPEN,PARTIALLY_COMPLETED,COMPLETEDorCANCELLED. However, one of my filter parameters will only consider the order with statusOPENorPARTIALLY_COMPLETED. So the retrieved list will have order withOPENorPARTIALLY_COMPLETEDstatus only.Furthermore, each order in
Ordersmodel also has the parameterunits. This represents theunitsat which the order was created. If the order is inOPENstate then all the units are unsold or if the order is inPARTIALLY_COMPLETEDthenunsold_units = units - sold_units. Deriving the unsold units forPARTIALLY_COMPLETEDorders is done after retrieving the list of orders.Now, let's assume the retrieved order list has 10 order and the total of
unsold_unitsof the list is 1000. However, I just need 100 units so if theunsold_unitsof the first3orders 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