MongoDB: Fix replication of undefined values #171
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When replicating Postgres rows, in some edge cases we have toasted (missing) values in rows. We use
undefined
in our internal "current_data" storage to indicate these values are missing, and wait until we have all values before processing the row in sync rules.With MongoDB replication, we always get the full document - we don't run into the case above. However, we had a bug where
undefined
values were kept as-is when replicating, triggering that logic. This caused rows with undefined values to not be replicated, without any indication why.Our tests appeared to check for this case, but didn't in reality. MongoDB deprecated the undefined value in BSON, making it very difficult to actually insert an undefined value in the database. Our tests actually only tested for
null
, and never forundefined
. The tests now use a nasty workaround usingmapReduce
to insert anundefined
value.This only changes the behavior for top-level
undefined
values. Behavior forundefined
in nested objects and arrays is unchanged:The the Discord thread reporting this issue.