This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,10 +98,14 @@ def restart_on_failure?
9898 def execute_request ( client )
9999 broker_response = send_broker_request ( client )
100100
101- service_instance . save_with_new_operation (
102- broker_response [ :instance ] || { } ,
103- broker_response [ :last_operation ] || { }
104- )
101+ ManagedServiceInstance . db . transaction do
102+ service_instance . lock!
103+ service_instance . last_operation . lock! if service_instance . last_operation
104+ service_instance . save_with_new_operation (
105+ broker_response [ :instance ] || { } ,
106+ broker_response [ :last_operation ] || { }
107+ )
108+ end
105109 end
106110
107111 def raise_if_cannot_proceed!
@@ -176,11 +180,15 @@ def operation_succeeded
176180
177181 def fail_last_operation ( msg )
178182 unless service_instance . blank?
179- service_instance . save_with_new_operation ( { } , {
180- type : operation_type ,
181- state : 'failed' ,
182- description : msg ,
183- } )
183+ ManagedServiceInstance . db . transaction do
184+ service_instance . last_operation . lock! if service_instance . last_operation
185+
186+ service_instance . save_with_new_operation ( { } , {
187+ type : operation_type ,
188+ state : 'failed' ,
189+ description : msg ,
190+ } )
191+ end
184192 end
185193 end
186194
You can’t perform that action at this time.
0 commit comments