Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Nov 28, 2024
1 parent ba2c623 commit 0c10d96
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
38 changes: 19 additions & 19 deletions src/meta/duplication/duplication_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool duplication_info::alter_progress(int partition_index,
}

if (confirm_entry.__isset.last_committed_decree) {
p.last_committed_decree = confirm_entry.last_committed_decree;
p.last_committed_decree = confirm_entry.last_committed_decree;
}

p.checkpoint_prepared = confirm_entry.checkpoint_prepared;
Expand All @@ -153,17 +153,17 @@ bool duplication_info::alter_progress(int partition_index,
}

if (p.volatile_decree == p.stored_decree) {
return false;
return false;
}

// Progress update is not supposed to be too frequent.
if (dsn_now_ms() < p.last_progress_update_ms + FLAGS_dup_progress_min_update_period_ms) {
return false;
}
// Progress update is not supposed to be too frequent.
if (dsn_now_ms() < p.last_progress_update_ms + FLAGS_dup_progress_min_update_period_ms) {
return false;
}

p.is_altering = true;
p.last_progress_update_ms = dsn_now_ms();
return true;
p.is_altering = true;
p.last_progress_update_ms = dsn_now_ms();
return true;
}

void duplication_info::persist_progress(int partition_index)
Expand All @@ -182,14 +182,14 @@ void duplication_info::persist_status()

if (!_is_altering) {
LOG_ERROR_PREFIX("the status of this duplication is not being altered: status={}, "
"next_status={}, master_app_id={}, master_app_name={}, "
"follower_cluster_name={}, follower_app_name={}"
duplication_status_to_string(_status),
duplication_status_to_string(_next_status),
app_id,
app_name,
remote_cluster_name,
remote_app_name);
"next_status={}, master_app_id={}, master_app_name={}, "
"follower_cluster_name={}, follower_app_name={}",
duplication_status_to_string(_status),
duplication_status_to_string(_next_status),
app_id,
app_name,
remote_cluster_name,
remote_app_name);
return;
}

Expand Down Expand Up @@ -233,8 +233,8 @@ void duplication_info::report_progress_if_time_up()
return;
}

_last_progress_report_ms = dsn_now_ms();
LOG_INFO("duplication report: {}", to_string());
_last_progress_report_ms = dsn_now_ms();
LOG_INFO("duplication report: {}", to_string());
}

duplication_info_s_ptr duplication_info::decode_from_blob(dupid_t dup_id,
Expand Down
2 changes: 1 addition & 1 deletion src/meta/duplication/duplication_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class duplication_info
int64_t volatile_decree{invalid_decree};
int64_t stored_decree{invalid_decree};

//
//
int64_t last_committed_decree{invalid_decree};

bool is_altering{false};
Expand Down
24 changes: 13 additions & 11 deletions src/meta/duplication/meta_duplication_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,26 +795,28 @@ void meta_duplication_service::do_update_partition_confirmed(
return;
}

const auto &path = get_partition_path(dup, std::to_string(partition_idx));
const auto &value = blob::create_from_bytes(std::to_string(confirm_entry.confirmed_decree));
const auto &path = get_partition_path(dup, std::to_string(partition_idx));

_meta_svc->get_meta_storage()->get_data(
path, [dup, rpc, partition_idx, confirm_entry, path, this](const blob &data) mutable {
auto value = blob::create_from_bytes(std::to_string(confirm_entry.confirmed_decree));

_meta_svc->get_meta_storage()->get_data(path, [=](const blob &data) mutable {
if (data.empty()) {
_meta_svc->get_meta_storage()->create_node(
path, std::move(value), [=]() mutable {
path, std::move(value), [dup, rpc, partition_idx, confirm_entry]() mutable {
dup->persist_progress(partition_idx);
rpc.response().dup_map[dup->app_id][dup->id].progress[partition_idx] =
confirm_entry.confirmed_decree;
});
return;
}
}

_meta_svc->get_meta_storage()->set_data(
path, std::move(value), [=]() mutable {
dup->persist_progress(partition_idx);
rpc.response().dup_map[dup->app_id][dup->id].progress[partition_idx] =
confirm_entry.confirmed_decree;
});
_meta_svc->get_meta_storage()->set_data(
path, std::move(value), [dup, rpc, partition_idx, confirm_entry]() mutable {
dup->persist_progress(partition_idx);
rpc.response().dup_map[dup->app_id][dup->id].progress[partition_idx] =
confirm_entry.confirmed_decree;
});

// duplication_sync_rpc will finally be replied when confirmed points
// of all partitions are stored.
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_state_service_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct meta_storage
/// Will fatal if node doesn't exists.
void set_data(std::string &&node, blob &&value, std::function<void()> &&cb);

void set_data(const std::string &node, blob &&value, std::function<void()> &&cb);
void set_data(const std::string &node, blob &&value, std::function<void()> &&cb)
{
set_data(std::string(node), std::move(value), std::move(cb));
}
Expand Down
3 changes: 2 additions & 1 deletion src/meta/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ void server_state::create_app(dsn::message_ex *msg)
duplicating
? fmt::format("master_cluster_name={}, master_app_name={}",
master_cluster->second,
gutil::FindWithDefault(request.options.envs, duplication_constants::kEnvMasterAppNameKey))
gutil::FindWithDefault(request.options.envs,
duplication_constants::kEnvMasterAppNameKey))
: "false");

auto option_match_check = [](const create_app_options &opt, const app_state &exist_app) {
Expand Down
5 changes: 2 additions & 3 deletions src/meta/test/duplication_info_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "gtest/gtest.h"
#include "runtime/app_model.h"

DSN_DECLARE_uint64(dup_progress_min_update_period_ms)
DSN_DECLARE_uint64(dup_progress_min_update_period_ms);

namespace dsn {
namespace replication {
Expand Down Expand Up @@ -96,8 +96,7 @@ class duplication_info_test : public testing::Test
ASSERT_FALSE(dup.alter_progress(1, entry));
ASSERT_FALSE(dup._progress[1].is_altering);

dup._progress[1].last_progress_update_ms -=
FLAGS_dup_progress_min_update_period_ms + 100;
dup._progress[1].last_progress_update_ms -= FLAGS_dup_progress_min_update_period_ms + 100;

entry.confirmed_decree = 15;
entry.checkpoint_prepared = true;
Expand Down

0 comments on commit 0c10d96

Please sign in to comment.