Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost updates #57

Open
jacekkopecky opened this issue Aug 4, 2022 · 0 comments
Open

Lost updates #57

jacekkopecky opened this issue Aug 4, 2022 · 0 comments

Comments

@jacekkopecky
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant