Skip to content

Commit

Permalink
Remove DurabilityVersion from ReplicationReplicaEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
as51340 committed May 24, 2024
1 parent d374afc commit 36c7e1b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/replication/include/replication/status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ struct ReplicationRoleEntry {

// from key: "__replication_replica:"
struct ReplicationReplicaEntry {
DurabilityVersion version =
DurabilityVersion::V4; // if not V4, no version was specified. No changes between [V1, V3]
// NOTE: There are multiple versions of ReplicationReplicaEntry, but we distinguish them in terms of
// ReplicationRoleEntry.
ReplicationClientConfig config;
friend bool operator==(ReplicationReplicaEntry const &, ReplicationReplicaEntry const &) = default;
};
Expand Down
3 changes: 1 addition & 2 deletions src/replication/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ bool ReplicationState::HandleVersionMigration(durability::ReplicationRoleEntry &
auto old_json = nlohmann::json::parse(old_data, nullptr, false);
if (old_json.is_discarded()) return false;
try {
durability::ReplicationReplicaEntry new_data = old_json.get<durability::ReplicationReplicaEntry>();
new_data.version = durability::DurabilityVersion::V4;
durability::ReplicationReplicaEntry const new_data = old_json.get<durability::ReplicationReplicaEntry>();
to_put.emplace(old_key, nlohmann::json(new_data).dump());
} catch (...) {
return false;
Expand Down
7 changes: 2 additions & 5 deletions src/replication/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ void from_json(const nlohmann::json &j, ReplicationRoleEntry &p) {
}

void to_json(nlohmann::json &j, const ReplicationReplicaEntry &p) {
auto common = nlohmann::json{{kVersion, p.version},
{kReplicaName, p.config.name},
auto common = nlohmann::json{{kReplicaName, p.config.name},
{kSyncMode, p.config.mode},
{kCheckFrequency, p.config.replica_check_frequency.count()}};

Expand All @@ -113,8 +112,6 @@ void to_json(nlohmann::json &j, const ReplicationReplicaEntry &p) {
}
void from_json(const nlohmann::json &j, ReplicationReplicaEntry &p) {
using io::network::Endpoint;
// This value did not exist until DurabilityVersion::V4, hence default DurabilityVersion::V3
DurabilityVersion version = j.value(kVersion, DurabilityVersion::V3);

const auto &key_file = j.at(kSSLKeyFile);
const auto &cert_file = j.at(kSSLCertFile);
Expand Down Expand Up @@ -142,6 +139,6 @@ void from_json(const nlohmann::json &j, ReplicationReplicaEntry &p) {
key_file.get_to(config.ssl->key_file);
cert_file.get_to(config.ssl->cert_file);
}
p = ReplicationReplicaEntry{.version = version, .config = std::move(config)};
p = ReplicationReplicaEntry{.config = std::move(config)};
}
} // namespace memgraph::replication::durability
1 change: 0 additions & 1 deletion tests/unit/replication_persistence_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ TEST(ReplicationDurability, ReplicaEntryMigrationNoVersionToV4) {
ReplicationReplicaEntry deser;
from_json(j, deser);
// Default version is V3
ASSERT_EQ(deser.version, DurabilityVersion::V3);
ASSERT_EQ(deser.config.name, "TEST_NAME");
ASSERT_EQ(deser.config.mode, ReplicationMode::ASYNC);
ASSERT_EQ(deser.config.repl_server_endpoint.GetAddress(), "000.123.456.789");
Expand Down

0 comments on commit 36c7e1b

Please sign in to comment.