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

Use session in document insert #1018

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

andraghetti
Copy link
Contributor

@andraghetti andraghetti commented Sep 5, 2024

Summary

This PR fixes a transactional integrity issue in Beanie by ensuring that document saves are correctly associated with the current transaction session.

Problem

When saving documents within a transaction using Beanie, a bug causes linked documents to be saved outside the transaction context if the session parameter is not explicitly provided. This behavior can lead to partial updates where some documents are persisted even if the transaction fails, undermining the purpose of using transactions.

Solution

The change explicitly adds session=session to the save function for documents within a transaction. This ensures that all document saves are bound to the active transaction, preventing unintended persistence of documents if the transaction is rolled back.

This fix maintains the atomicity of transactions by ensuring all operations are executed within the transaction context, thus preserving data consistency and integrity.

Copy link
Contributor

@adeelsohailahmed adeelsohailahmed left a comment

Choose a reason for hiding this comment

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

Good catch! Thank you for your contribution. Looks good to me.

@andraghetti
Copy link
Contributor Author

@adeelsohailahmed Hi! Is there a way to expedite the process? Can we ping other collaborators to review?

@adeelsohailahmed adeelsohailahmed requested a review from a team September 9, 2024 15:41
@adeelsohailahmed
Copy link
Contributor

@adeelsohailahmed Hi! Is there a way to expedite the process? Can we ping other collaborators to review?

Beyond requesting a review from the team (which I've already done), I don't think there's much we can do.

@andraghetti
Copy link
Contributor Author

@adeelsohailahmed Hi! Is there a way to expedite the process? Can we ping other collaborators to review?

Beyond requesting a review from the team (which I've already done), I don't think there's much we can do.

That’s perfect! Thank you 👍

@adeelsohailahmed adeelsohailahmed requested review from a team and 07pepa September 12, 2024 19:12
Copy link

@Riverfount Riverfount left a comment

Choose a reason for hiding this comment

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

LGTM

@andraghetti
Copy link
Contributor Author

Nice! Thank you! Can somebody merge it?

@adeelsohailahmed adeelsohailahmed merged commit 8b5446e into BeanieODM:main Sep 19, 2024
19 checks passed
@andraghetti andraghetti deleted the missing-session-insert branch September 19, 2024 14:57
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.

4 participants