Skip to content

Lost updatesΒ #57

@jacekkopecky

Description

@jacekkopecky

Firstly, thank you for creating this example, it's been great for me trying to learn GraphQL.

One query I wrote when thinking about transactions was to check in two pets at the same time. This uncovered a race condition where the code here:

await customers.updateOne(
{ username: currentCustomer.username },
{
$set: {
checkoutHistory: [checkout, ...currentCustomer.checkoutHistory]
}
}
);

uses currentCustomer from the context without updating it. So both checkins happen, the first one updates my checkout history to include the first checkout, and the second checkin then overwrites my history as only containing that second checkin. This means my first checkin is lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions