You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes Synchronization & Deletion can technically be executed concurrently by the same user. This shouldn't be occurring as there is no use case for such a scenario. Also, this can lead to race conditions. For example, when executing Synchronization, which contains the following logic
Get all Changes by UserId
Process Changes
Delete Changes
If Process 1 is completes Delete Changes and Process 2 runs Process Changes, then double processing will be executed. Retrieval from external sources such as Images might fail as these resources might have been deleted already.
Let's add a new container Synchronizing, which contains {userId, state}. Both id & partition key will use userId.
When Synchronization begins, add the userId with state isSynchronizing to Synchronizing. If an entry with the userId exists, the operation fails.
Run Synchronization.
On Synchronization complete, set existing state to pendingDeletion.
When Deletion begins, set existing state to isDeleting. If an entry with the userId exists and the state is not pendingDeletion, or if an entry does not exist, the operation fails.
On Deletion complete, delete entry.
To handle the scenario where either the Client or Server errors out, let's set ttl to 30s for auto-timeout. A race condition might occur if the ttl expires too quickly before the operation completes. To mitigate this, let's update ttl periodically while Synchronization is occurring.
The text was updated successfully, but these errors were encountered:
Changes Synchronization & Deletion can technically be executed concurrently by the same user. This shouldn't be occurring as there is no use case for such a scenario. Also, this can lead to race conditions. For example, when executing Synchronization, which contains the following logic
If Process 1 is completes
Delete Changes
and Process 2 runsProcess Changes
, then double processing will be executed. Retrieval from external sources such as Images might fail as these resources might have been deleted already.Let's add a new container
Synchronizing
, which contains {userId, state}. Both id & partition key will useuserId
.isSynchronizing
toSynchronizing
. If an entry with the userId exists, the operation fails.pendingDeletion
.isDeleting
. If an entry with the userId exists and the state is notpendingDeletion
, or if an entry does not exist, the operation fails.To handle the scenario where either the Client or Server errors out, let's set
ttl
to 30s for auto-timeout. A race condition might occur if thettl
expires too quickly before the operation completes. To mitigate this, let's updatettl
periodically while Synchronization is occurring.The text was updated successfully, but these errors were encountered: