My application is running inside AWS lambda and needs to write to postgresql. There is a scenario that two lambdas will write to the same row in the db table. Below is the case:
Lambda1:
receive order processing event then update order#1 status to processing
Lambda2:
receive order completed event then update order#1 status to completed
.
In above scenario, Lambda1 and Lambda2 can happen in any order. how can I make sure the final status of the order#1
is completed
not processing
?
I can do a query before update, but what happen if the other lambda writes to the table in between?