Tuesday 23 April 2019

How to avoid race condition with Async/Await Database operations ?

Hello, there.​Image the following scenario: Request "A" asks for a item in a list and its status is set to "false" on a MongoDB instance. In the same time, a request "B" arrives to Node.js and asks for a item and, like request "A", the item status is set to "false" too. The question is: How to avoid request "A" and "B" of ask for the same item in the list? I know that Node.js is single threaded, but if these database operations were executed without Async/Await something can goes wrong due to race condition, right ?

Submitted April 23, 2019 at 01:05PM by giocruz

No comments:

Post a Comment