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

RCORE-1977 Empty reciprocal changesets lead to crashes or data divergence #7955

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Fixed an "invalid column key" exception when using a RQL "BETWEEN" query on an int or timestamp property across links. ([#7935](https://github.com/realm/realm-core/issues/7935), since v14.10.1)
* Fixed conflict resolution bug related to ArrayErase and Clear instructions, which could sometimes cause an "Invalid prior_size" exception to prevent synchronization ([#7893](https://github.com/realm/realm-core/issues/7893), since v14.8.0).
* Fixed bug which would prevent eventual consistency during conflict resolution. Affected clients would experience data divergence and potentially consistency errors as a result. ([PR #7955](https://github.com/realm/realm-core/pull/7955), since v14.8.0)

### Breaking changes
* None.
Expand Down
2 changes: 1 addition & 1 deletion src/realm/sync/noinst/client_history_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void ClientHistory::set_reciprocal_transform(version_type version, BinaryData da
std::size_t index = size_t(version - m_sync_history_base_version) - 1;
REALM_ASSERT(index < sync_history_size());

if (data.is_null()) {
if (data.size() == 0) {
m_arrays->reciprocal_transforms.set(index, BinaryData{"", 0}); // Throws
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/realm/sync/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,8 +2590,9 @@ size_t Transformer::transform_remote_changesets(TransformHistory& history, file_
Changeset& Transformer::get_reciprocal_transform(TransformHistory& history, file_ident_type local_file_ident,
version_type version, const HistoryEntry& history_entry)
{
auto& changeset = m_reciprocal_transform_cache[version]; // Throws
if (changeset.empty()) {
auto [it, success] = m_reciprocal_transform_cache.insert({version, Changeset{}}); // Throws
if (success) {
Changeset& changeset = it->second;
bool is_compressed = false;
ChunkedBinaryData data = history.get_reciprocal_transform(version, is_compressed);
ChunkedBinaryInputStream in{data};
Expand All @@ -2613,7 +2614,7 @@ Changeset& Transformer::get_reciprocal_transform(TransformHistory& history, file
origin_file_ident = local_file_ident;
changeset.origin_file_ident = origin_file_ident;
}
return changeset;
return it->second;
}


Expand Down
Loading
Loading