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

🪲 Fix accidental object sharing in Dynamo layer #5353

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

rix0rrr
Copy link
Collaborator

@rix0rrr rix0rrr commented Apr 2, 2024

As discovered in #5350 by @jpelay, the Dynamo emulation layer has a bug that can lead to accidental data sharing between different requests, because the DB layer hands out references to long-lived objects. If those get mutated in-place by a reader, those mutations accidentally affect the stored in-memory copy of the database.

How I did this:

  • Write the tests first to encode the contract that mutations to retrieved (or inserted) objects shouldn't persist to objects retrieved in other queries.
  • Replace copy.copy() with copy.deepcopy() everywhere 😳 oops!

How to test

Follow the steps in #5350.

As discovered in #5350 by @jpelay, the Dynamo emulation layer has
a bug that can lead to accidental data sharing between different
requests, because the DB layer hands out references to long-lived
objects. If those get mutated in-place by a reader, those mutations
accidentally affect the stored in-memory copy of the database.
Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

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

Ah yeah, this is a better fix than mine 😅 Thanks for the quick fix, and the pointer.

Copy link
Contributor

mergify bot commented Apr 2, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 97d245d into main Apr 2, 2024
12 checks passed
@mergify mergify bot deleted the dynamo-structure-sharing branch April 2, 2024 16:44
Copy link
Contributor

mergify bot commented Apr 2, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

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

Successfully merging this pull request may close these issues.

2 participants