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

Workaround issue when initiating sync on a copied realm file #4878

Merged
merged 6 commits into from
Sep 15, 2021

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Aug 27, 2021

The problem is that the server does not know that the client has already
integrated some server versions, and therefore it sends down 0 as
progress/upload/last_integrated_server_version. On the client this number
may be bigger and in this case that number will not be overwritten with 0.

On the server we have to change the handling of the upload cursor in case
a newly created client indicates that is has already integrated some server
changesets.

What, How & Why?

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)

@jedelbo jedelbo force-pushed the je/fix-write-copy branch from d5fc377 to 32963a5 Compare August 27, 2021 11:39
The problem is that the server does not know that the client has already
integrated some server versions, and therefore it sends down 0 as
progress/upload/last_integrated_server_version. On the client this number
may be bigger and in this case that number will not be overwritten with 0.
There may still be issues on the server, however.
If the IDENT message indicates that the newly created client has
already integraded some server changesets, adjust the upload threshold
accordingly- If the threshold is ahead of the upload cursor stored in
the history, use the threshold values.
@jedelbo jedelbo requested review from jbreams and simonask August 30, 2021 09:55
@jedelbo jedelbo marked this pull request as ready for review August 30, 2021 09:56
@@ -829,8 +831,10 @@ void ClientHistoryImpl::update_sync_progress(const SyncProgress& progress,
RefOrTagged::make_tagged(progress.latest_server_version.salt)); // Throws
root.set(s_progress_upload_client_version_iip,
RefOrTagged::make_tagged(progress.upload.client_version)); // Throws
root.set(s_progress_upload_server_version_iip,
RefOrTagged::make_tagged(progress.upload.last_integrated_server_version)); // Throws
if (progress.upload.last_integrated_server_version > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the current version of s_progres_upload_server_version_iip is zero, would this be a noop without this conditional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure I understand the question. If current value is zero and progress value is zero then it is obviously a noop. The test just makes sure that we will not overwrite a non-zero value with a zero.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are answering my question without understanding it 😄 . We were changing this from unconditionally setting a value to conditionally setting a value, and I wanted to verify the preconditions. Can you add a comment about why we're conditionally setting this here?

@@ -1776,6 +1777,126 @@ TEST_CASE("app: set new embedded object", "[sync][app]") {
}
}

TEST_CASE("app: make distributable client file", "[sync][app]") {
std::unique_ptr<GenericNetworkTransport> (*factory)() = [] {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace lines 1781-1798 with a call to get_integration_config()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

realm_config.sync_config = std::make_shared<realm::SyncConfig>(app->current_user(), bson::Bson("foo"));
realm_config.sync_config->client_resync_mode = ClientResyncMode::Manual;
realm_config.sync_config->error_handler = [](std::shared_ptr<SyncSession>, SyncError error) {
std::cerr << error.message << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to override the sync handler here? Should we assert that there is no error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed


realm::Realm::Config realm_config;
realm_config.sync_config = std::make_shared<realm::SyncConfig>(app->current_user(), bson::Bson("foo"));
realm_config.sync_config->client_resync_mode = ClientResyncMode::Manual;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the default value works fine here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

realm_config.sync_config = std::make_shared<realm::SyncConfig>(app->current_user(), bson::Bson("foo"));
realm_config.sync_config->client_resync_mode = ClientResyncMode::Manual;
realm_config.sync_config->error_handler = [](std::shared_ptr<SyncSession>, SyncError error) {
std::cerr << error.message << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to abort if we get here because that's how we'll know if the server sent us an error message, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed


PROJECT_DIR=$(git rev-parse --show-toplevel)
MDBREALM_TEST_SERVER_TAG=$(grep MDBREALM_TEST_SERVER_TAG ${PROJECT_DIR}/dependencies.list |cut -f 2 -d=)
docker run --rm -p 9090:9090 -v ~/.aws/credentials:/root/.aws/credentials -it docker.pkg.github.com/realm/ci/mongodb-realm-test-server:${MDBREALM_TEST_SERVER_TAG}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want, you can also just run ./evergreen/install_baas.sh -w baas-work-dir with your AWS credentials in the correct environment variables and it will the latest version of baas deployed to prod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, but I just wanted a script that starts the version we refer to in the dependencies. I think that is the one that is run in Jenkins CI.

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH, I think we should get rid of the dependencies.list for deciding what version of baas to run. It's chronically out of date, sometimes by months or quarters. Can you change the name of this file to be something like run_baas_docker_image.sh to clarify what it's actually doing? Otherwise I don't have an objection to small utility scripts like this, just wanted you to know that there's already something in the codebase that will accomplish the same task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I run ./evergreen/install_baas.sh -w baas-work-dir, I get Unsupported platform linuxmint 19.3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will rename the script.

@@ -24,14 +24,14 @@ target_link_libraries(RealmTrawler Storage)

add_executable(RealmBrowser EXCLUDE_FROM_ALL realm_browser.cpp )
set_target_properties(RealmBrowser PROPERTIES
OUTPUT_NAME "realm-browser-6"
OUTPUT_NAME "realm-browser-10"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just remove these suffixes? What value are they adding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are adding the value that It is build into the name which version it can handle. I have to have multiple versions around so that I can open whatever realm file I get from a customer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, if it's part of your workflow then okay. I wish this were configurable. We use these tools outside of your debugging processes - e.g. the cloud team depends on them. @tkaye407 , will you need to update anything if we rename realm2json like this?

Copy link
Contributor

Choose a reason for hiding this comment

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

We currently just pin to a specific version (though we probably should be able to pick up the latest merge), but once this goes in I can update the version / name of the executable that we link to in our evergreen config. Thanks for pointing out

@jedelbo jedelbo merged commit fb12944 into master Sep 15, 2021
@jedelbo jedelbo deleted the je/fix-write-copy branch September 15, 2021 09:46
dianaafanador3 pushed a commit that referenced this pull request Oct 27, 2021
The problem is that the server does not know that the client has already
integrated some server versions, and therefore it sends down 0 as
progress/upload/last_integrated_server_version. On the client this number
may be bigger and in this case that number will not be overwritten with 0.

On the server side, the following behavior is expected: If the IDENT message
indicates that the newly created client has already integraded some server
changesets, adjust the upload threshold accordingly- If the threshold is ahead
of the upload cursor stored in the history, use the threshold values.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants