I can’t disclose the actual problem statement here. However, I will try to explain my use case with a similar situation.
I have the details of a an order placed by a user. the details like order number(unique identifier), order price are fixed and will not be changed. However the state of order(PLACED/SHIPPED/DELIVERED/RETURNED) and stateUpdateTimestamp can be changed.
There is an array of queries which a user can place for that order. Here operation can be performed on the query by multiple departments in async mode.
operation:'placed an exchange',
operation:'checking if wrong item dispatched',
In the above use case we have following scenarios where two simultaneous updates may be performed on same part of document. In both the scenarios I have the ‘ordernumber’ provided by user to identify the document.
- The ‘orderstate’ array can be updated simultaneously by two threads. According to subdocument api, two concurrent subdoc arrayAppend operations to the same array will both succeed, never overwriting the other. So in this case two concurrent appends to ‘orderstate’ will not result in loss of an ‘orderstate’ entry. Please confirm on this.
- More than one threads can concurrently update the ‘query.operation’ and ‘query.queryUpdatedTimestamp’ field of a query. Here I need the cas value to be checked.
Please share your opinion on the solution and confirm our understanding.