Skip to content

Commit

Permalink
feat(dup): parameterize the period seconds of duplication sync (apach…
Browse files Browse the repository at this point in the history
…e#1639)

apache#766

The period seconds of duplication to sync data from local cluster to remote
cluster is hard code (10 seconds) now, this patch adds a parameter for it.

config changes:
```diff
+[replication]
+duplication_sync_period_second = 10
```
  • Loading branch information
acelyc111 authored Oct 18, 2023
1 parent 13a45ab commit 8d7c91b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/replica/duplication/duplication_sync_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@
#include "runtime/task/async_calls.h"
#include "runtime/task/task_code.h"
#include "utils/autoref_ptr.h"
#include "utils/chrono_literals.h"
#include "utils/error_code.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/threadpool_code.h"

DSN_DEFINE_uint64(
replication,
duplication_sync_period_second,
10,
"The period seconds of duplication to sync data from local cluster to remote cluster");

namespace dsn {
namespace replication {
using namespace literals::chrono_literals;

DEFINE_TASK_CODE(LPC_DUPLICATION_SYNC_TIMER, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)

Expand Down Expand Up @@ -169,14 +178,14 @@ void duplication_sync_timer::close()

void duplication_sync_timer::start()
{
LOG_INFO("run duplication sync periodically in {}s", DUPLICATION_SYNC_PERIOD_SECOND);
LOG_INFO("run duplication sync periodically in {}s", FLAGS_duplication_sync_period_second);

_timer_task = tasking::enqueue_timer(LPC_DUPLICATION_SYNC_TIMER,
&_stub->_tracker,
[this]() { run(); },
DUPLICATION_SYNC_PERIOD_SECOND * 1_s,
FLAGS_duplication_sync_period_second * 1_s,
0,
DUPLICATION_SYNC_PERIOD_SECOND * 1_s);
FLAGS_duplication_sync_period_second * 1_s);
}

std::multimap<dupid_t, duplication_sync_timer::replica_dup_state>
Expand Down
5 changes: 0 additions & 5 deletions src/replica/duplication/duplication_sync_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "duplication_types.h"
#include "replica/replica.h"
#include "runtime/task/task.h"
#include "utils/chrono_literals.h"
#include "utils/zlocks.h"

namespace dsn {
Expand All @@ -35,10 +34,6 @@ class error_code;
namespace replication {
class replica_stub;

using namespace literals::chrono_literals;

constexpr int DUPLICATION_SYNC_PERIOD_SECOND = 10;

// Per-server(replica_stub)-instance.
class duplication_sync_timer
{
Expand Down

0 comments on commit 8d7c91b

Please sign in to comment.