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

Update mongo repsert and replace calls #1550

Merged
merged 2 commits into from
Sep 13, 2024
Merged

Conversation

darycabrera
Copy link
Contributor

@darycabrera darycabrera commented Sep 12, 2024

Replace mongo driver save and replace API calls with updateMany to restore correct behavior in MongoDB >=6.0

This is an extension of #1545. The change in behavior lies in the underlying driver update function which is called indirectly via persistent's repsert and replace APIs. In this function, the driver uses a write concern of 0 overriding the preference set by the mongo access mode or default write concern as configured in the DB. In test suites or other scenarios where the written data is immediately queried for again from a secondary this can result in flaky "Not Found" failures.

I have opened a PR against the driver library to directly address this issue among others, however, until that change gets approved and merged we can circumvent the problem here in this repository which has more active maintenance.

Replace mongo driver save and replace calls with updateMany to
restore correct behavior in MongoDB >=6.0
Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a change in behavior, please do a minor version bump and update the changelog with a description. I'll get it released soon.

Thanks!

Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how does this impact mongodb users that are using the prior version? Does everything still work as expected?

persistent-mongoDB/ChangeLog.md Outdated Show resolved Hide resolved
persistent-mongoDB/persistent-mongoDB.cabal Outdated Show resolved Hide resolved
Co-authored-by: Matt Parsons <[email protected]>
@darycabrera
Copy link
Contributor Author

Also, how does this impact mongodb users that are using the prior version? Does everything still work as expected?

Yes, there should be no impact; the change is backwards compatible

@parsonsmatt parsonsmatt merged commit a2fdcde into yesodweb:master Sep 13, 2024
7 checks passed
@parsonsmatt
Copy link
Collaborator

Thanks! Uploaded to Hackage

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

Successfully merging this pull request may close these issues.

2 participants