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

Update BIND message with reason on what a session is used for #6902

Merged
merged 8 commits into from
Aug 19, 2023

Conversation

danieltabacaru
Copy link
Collaborator

@danieltabacaru danieltabacaru commented Aug 16, 2023

What, How & Why?

The sync client relies on the server sending the schema instructions in case of a client reset. But as part of "Allow breaking changes in dev mode" project the server waits to receive the client schema before sending its schema. When dealing with a client reset the client never sends its schema and therefore it does not receive the server schema anymore. This PR introduces a fix so the server can differentiate if a synchronization session is used for a client reset or not, so it can send its schema.

The version of the sync protocol was bumped to 10.

☑️ ToDos

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

@danieltabacaru danieltabacaru marked this pull request as ready for review August 16, 2023 21:23
Copy link
Contributor

@kmorkos kmorkos left a comment

Choose a reason for hiding this comment

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

can we hold off on the protocol bump until #6476 is merged? (assuming the timeframe for that is no more than a few days cc @michael-wb)

@@ -52,6 +52,17 @@ std::string ClientResetOperation::get_fresh_path_for(const std::string& path)
return path + fresh_suffix;
}

bool ClientResetOperation::is_fresh_path(const std::string& path)
{
const std::string fresh_suffix = ".fresh";
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 add this as a const somewhere so we don't risk it going out of sync with get_fresh_path_for ?

Comment on lines +873 to +875
session_config.session_reason = ClientResetOperation::is_fresh_path(m_config.path)
? sync::SessionReason::ClientReset
: sync::SessionReason::Sync;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any other way to tell if it's a client reset other than the path?

Perhaps you could set a "client reset in progress value" in the SyncSession created in download_fresh_realm()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could do that, but we depend on when the session becomes active and sync::Session is created (we need to have the value set before that, otherwise it's too late). Ideally, this value would be set/inferred in the constructor of the SyncSession, but we need to pass the value through several layers. I can make the change if you feel strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK - given our current session structure, looking for the path suffix seems like the most efficient approach, and get_fresh_path_for() is only used during download_fresh_realm().

@@ -1852,6 +1852,7 @@ void Session::send_bind_message()
if (auto migrated_partition = get_migration_store()->get_migrated_partition()) {
bind_json_data["migratedPartition"] = *migrated_partition;
}
bind_json_data["sessionReason"] = static_cast<uint64_t>(get_session_reason());
Copy link
Contributor

Choose a reason for hiding this comment

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

@kmorkos - should this be a string value, since most of our protocol "enum" values are strings instead of ints?

Copy link
Contributor

Choose a reason for hiding this comment

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

i have no strong preference. thoughts @yaseenmongo?

regardless, it would be nice to represent a "normal" session as the zero-value of whatever type we choose for backwards compatibility

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A normal session has a value of zero indeed

Choose a reason for hiding this comment

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

I don't have a preference either. Since this is a wire protocol detail, I would generally say an int is better just for the slight efficiency gain, but it's not that much data to really matter. I'll defer to you folks 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is an integer then 🙂

Choose a reason for hiding this comment

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

One note, one potential benefit of using an int is that we could use convert it as a bitmask in the future if we ever needed to communicate multiple reasons why a client is reconnecting to sync e.g. ClientReset and SomeOtherReason. But I'm not sure if that will ever become a requirement.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK with that

@danieltabacaru
Copy link
Collaborator Author

can we hold off on the protocol bump until #6476 is merged? (assuming the timeframe for that is no more than a few days cc @michael-wb)

we'll do that.

@danieltabacaru danieltabacaru merged commit 824429f into master Aug 19, 2023
@danieltabacaru danieltabacaru deleted the dt/update_bind_message branch August 19, 2023 06:40
@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