aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnaury <snaury@ydb.tech>2023-09-14 17:22:40 +0300
committersnaury <snaury@ydb.tech>2023-09-14 17:44:08 +0300
commit2a070f2af07aa540803c66b721f544c8b722bf52 (patch)
treeeaa60c7a8f46ade2386ce37063eb4b56b5c0d86f
parentaab08a6fe3bcdbe14fa7e61c38825fecd152b7a0 (diff)
downloadydb-2a070f2af07aa540803c66b721f544c8b722bf52.tar.gz
Restore 50ms time shift in coordinator time for compatibility with older versions KIKIMR-19354
-rw-r--r--ydb/core/protos/config.proto5
-rw-r--r--ydb/core/tx/coordinator/coordinator_impl.cpp11
-rw-r--r--ydb/core/tx/coordinator/coordinator_impl.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto
index 7513e7be55..4a31457187 100644
--- a/ydb/core/protos/config.proto
+++ b/ydb/core/protos/config.proto
@@ -1557,6 +1557,11 @@ message TImmediateControlsConfig {
MinValue: 0,
MaxValue: 10000,
DefaultValue: 250 }];
+ optional uint64 PlanAheadTimeShiftMs = 4 [(ControlOptions) = {
+ Description: "Wall-clock time shift in milliseconds when planning ahead (50ms for compatibility with older versions)",
+ MinValue: 0,
+ MaxValue: 86400000,
+ DefaultValue: 50 }];
}
message TSchemeShardControls {
diff --git a/ydb/core/tx/coordinator/coordinator_impl.cpp b/ydb/core/tx/coordinator/coordinator_impl.cpp
index 46d9227c62..904358d7f5 100644
--- a/ydb/core/tx/coordinator/coordinator_impl.cpp
+++ b/ydb/core/tx/coordinator/coordinator_impl.cpp
@@ -58,6 +58,7 @@ TTxCoordinator::TTxCoordinator(TTabletStorageInfo *info, const TActorId &tablet)
, EnableLeaderLeases(1, 0, 1)
, MinLeaderLeaseDurationUs(250000, 1000, 5000000)
, VolatilePlanLeaseMs(250, 0, 10000)
+ , PlanAheadTimeShiftMs(50, 0, 86400000)
#ifdef COORDINATOR_LOG_TO_FILE
, DebugName(Sprintf("/tmp/coordinator_db_log_%" PRIu64 ".%" PRIi32 ".%" PRIu64 ".gz", TabletID(), getpid(), tablet.LocalId()))
, DebugLogFile(DebugName)
@@ -222,7 +223,8 @@ bool TTxCoordinator::AllowReducedPlanResolution() const {
void TTxCoordinator::SchedulePlanTick() {
const ui64 resolution = Config.Resolution;
- const TInstant now = TAppData::TimeProvider->Now();
+ const ui64 timeShiftMs = PlanAheadTimeShiftMs;
+ const TInstant now = TAppData::TimeProvider->Now() + TDuration::MilliSeconds(timeShiftMs);
const TMonotonic monotonic = AppData()->MonotonicTimeProvider->Now();
// Step corresponding to current time
@@ -287,7 +289,8 @@ void TTxCoordinator::SchedulePlanTickExact(ui64 next) {
return;
}
- const TInstant now = TAppData::TimeProvider->Now();
+ const ui64 timeShiftMs = PlanAheadTimeShiftMs;
+ const TInstant now = TAppData::TimeProvider->Now() + TDuration::MilliSeconds(timeShiftMs);
const TMonotonic monotonic = AppData()->MonotonicTimeProvider->Now();
TDuration delay = Min(TInstant::MilliSeconds(next) - now, MaxPlanTickDelay);
@@ -333,7 +336,8 @@ void TTxCoordinator::Handle(TEvPrivate::TEvPlanTick::TPtr &ev, const TActorConte
}
const ui64 resolution = Config.Resolution;
- const TInstant now = TAppData::TimeProvider->Now();
+ const ui64 timeShiftMs = PlanAheadTimeShiftMs;
+ const TInstant now = TAppData::TimeProvider->Now() + TDuration::MilliSeconds(timeShiftMs);
// Check the step corresponding to current time
ui64 current = now.MilliSeconds();
@@ -491,6 +495,7 @@ void TTxCoordinator::IcbRegister() {
AppData()->Icb->RegisterSharedControl(EnableLeaderLeases, "CoordinatorControls.EnableLeaderLeases");
AppData()->Icb->RegisterSharedControl(MinLeaderLeaseDurationUs, "CoordinatorControls.MinLeaderLeaseDurationUs");
AppData()->Icb->RegisterSharedControl(VolatilePlanLeaseMs, "CoordinatorControls.VolatilePlanLeaseMs");
+ AppData()->Icb->RegisterSharedControl(PlanAheadTimeShiftMs, "CoordinatorControls.PlanAheadTimeShiftMs");
IcbRegistered = true;
}
}
diff --git a/ydb/core/tx/coordinator/coordinator_impl.h b/ydb/core/tx/coordinator/coordinator_impl.h
index fc6249d821..875049e77b 100644
--- a/ydb/core/tx/coordinator/coordinator_impl.h
+++ b/ydb/core/tx/coordinator/coordinator_impl.h
@@ -573,6 +573,7 @@ private:
TControlWrapper EnableLeaderLeases;
TControlWrapper MinLeaderLeaseDurationUs;
TControlWrapper VolatilePlanLeaseMs;
+ TControlWrapper PlanAheadTimeShiftMs;
TVolatileState VolatileState;
TConfig Config;