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

Avoid corrupt documents #248

Merged
merged 8 commits into from
Nov 27, 2020
Merged

Conversation

dgknght
Copy link
Contributor

@dgknght dgknght commented Nov 25, 2020

When tracking history on deeply embedded documents where callbacks are cascaded from the root document, incrementing the version number of the embedded docs that are removed because an ancestor is removed causes conflicts in the atomic update, which are then written into an empty document in the 2nd pass, causing corrupt embedded documents to be persisted. Here we avoid updating the version of a document if an ancestor is being destroyed.

Doug Knight added 7 commits November 25, 2020 10:55
If an embedded document has its version incremented, but an ancester
is flagged for destroy and the root document is not, then this causes
conflicts, which are written to the otherwise empty embedded document,
leaving a corrupt document in storage.

Note that this only happends with the parent document cascades
callbacks.
@dblock
Copy link
Collaborator

dblock commented Nov 26, 2020

rubocop -a will fix the build

@dblock
Copy link
Collaborator

dblock commented Nov 26, 2020

This makes sense, tough one, will merge on green.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.4%) to 98.056% when pulling 6e2c459 on getaroom:avoid-corrupt-documents into 2935da0 on mongoid:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.4%) to 98.056% when pulling 6e2c459 on getaroom:avoid-corrupt-documents into 2935da0 on mongoid:master.

@coveralls
Copy link

coveralls commented Nov 27, 2020

Coverage Status

Coverage increased (+0.002%) to 99.419% when pulling 6e2c459 on getaroom:avoid-corrupt-documents into 2935da0 on mongoid:master.

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.

3 participants