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

Make sure very large changesets in bootstraps do not crash the sync client #6220

Merged
merged 4 commits into from
Jan 23, 2023

Conversation

jbreams
Copy link
Contributor

@jbreams jbreams commented Jan 20, 2023

What, How & Why?

This fixes the sync client so that if it receives a FLX bootstrap changeset larger than what can fit into a BinaryColumn, it treats that as a bad_changeset_size error and fails gracefully rather than crashing the process.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

@cla-bot cla-bot bot added the cla: yes label Jan 20, 2023
@jbreams jbreams removed their assignment Jan 20, 2023
}
catch (const LogicError& ex) {
if (ex.kind() == LogicError::binary_too_big) {
IntegrationException ex(ClientError::bad_changeset,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can even throw bad_changeset_size if you wanted it since there is both a ClientError and ProtocolError and we can translate it before sending to the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@jbreams jbreams marked this pull request as ready for review January 20, 2023 22:07
Copy link
Contributor

@michael-wb michael-wb left a comment

Choose a reason for hiding this comment

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

LGTM - makes me wonder if there are other errors we should be catching as well in the future, but definitely need to not crash in this case.

@jbreams jbreams requested a review from ironage January 23, 2023 18:18
@jbreams
Copy link
Contributor Author

jbreams commented Jan 23, 2023

@ironage , could you take a look while @danieltabacaru is out?

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

This seems fine as a stopgap fix, but it is still bad news that the server can sometimes cause this unrecoverable error on a client. AFAIK, core doesn't actually need to enforce the size limit in this case because it is the history. IIRC Realm can store arbitrary length binaries and the only reason we restrict the length is because we want to respect MongoDB's server side limit. I'd expect that if we used a different API to set the binary which didn't do the size check, everything should just work?

@jbreams
Copy link
Contributor Author

jbreams commented Jan 23, 2023

Yeah, there's a server-side fix for this captured in BAAS-19105 and this is a stop-gap fix.

@jbreams jbreams merged commit 715e870 into master Jan 23, 2023
@jbreams jbreams deleted the jbr/flx_sync_big_bootstrap branch January 23, 2023 19:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants