mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Add check to make sure maintenance time is positive and update the documentation
This commit is contained in:
parent
b34825a0e6
commit
2e825908dc
@ -949,7 +949,7 @@ that process, and wait for necessary data to be moved away.
|
||||
#. ``\xff\xff/management/options/failed/force`` Read/write. Setting this key disables safety checks for writes to ``\xff\xff/management/failed/<exclusion>``. Setting this key only has an effect in the current transaction and is not persisted on commit.
|
||||
#. ``\xff\xff/management/min_required_commit_version`` Read/write. Changing this key will change the corresponding system key ``\xff/minRequiredCommitVersion = [[Version]]``. The value of this special key is the literal text of the underlying ``Version``, which is ``int64_t``. If you set the key with a value failed to be parsed as ``int64_t``, ``special_keys_api_failure`` will be thrown. In addition, the given ``Version`` should be larger than the current read version and smaller than the upper bound(``2**63-1-version_per_second*3600*24*365*1000``). Otherwise, ``special_keys_api_failure`` is thrown. For more details, see help text of ``fdbcli`` command ``advanceversion``.
|
||||
#. ``\xff\xff/management/profiling/<client_txn_sample_rate|client_txn_size_limit>`` Read/write. Changing these two keys will change the corresponding system keys ``\xff\x02/fdbClientInfo/<client_txn_sample_rate|client_txn_size_limit>``, respectively. The value of ``\xff\xff/management/client_txn_sample_rate`` is a literal text of ``double``, and the value of ``\xff\xff/management/client_txn_size_limit`` is a literal text of ``int64_t``. A special value ``default`` can be set to or read from these two keys, representing the client profiling is disabled. In addition, ``clear`` in this range is not allowed. For more details, see help text of ``fdbcli`` command ``profile client``.
|
||||
#. ``\xff\xff/management/maintenance/<zone_id> := <seconds>`` Read/write. Set/clear a key in this range will change the corresponding system key ``\xff\x02/healthyZone``. The value is a literal text of ``int`` which represents the remaining time for the zone to be in maintenance. Only one zone is allowed to be in maintenance at the same time. Setting a new key in the range will override the old one and the transaction will throw ``special_keys_api_failure`` error if more than one zone is given. For more details, see help text of ``fdbcli`` command ``maintenance``.
|
||||
#. ``\xff\xff/management/maintenance/<zone_id> := <seconds>`` Read/write. Set/clear a key in this range will change the corresponding system key ``\xff\x02/healthyZone``. The value is a literal text of a positive ``double`` which represents the remaining time for the zone to be in maintenance. Commiting with an invalid value will throw ``special_keys_api_failure``. Only one zone is allowed to be in maintenance at the same time. Setting a new key in the range will override the old one and the transaction will throw ``special_keys_api_failure`` error if more than one zone is given. For more details, see help text of ``fdbcli`` command ``maintenance``.
|
||||
In addition, a special key ``\xff\xff/management/maintenance/IgnoreSSFailures`` in the range, if set, will disable datadistribution for storage server failures.
|
||||
It is doing the same thing as the fdbcli command ``datadistribution disable ssfailure``.
|
||||
Maintenance mode will be unable to use until the key is cleared, which is the same as the fdbcli command ``datadistribution enable ssfailure``.
|
||||
|
@ -1937,7 +1937,7 @@ ACTOR static Future<Standalone<RangeResultRef>> MaintenanceGetRangeActor(ReadYou
|
||||
if ((healthyZone.first == ignoreSSFailuresZoneString) ||
|
||||
(healthyZone.second > ryw->getTransaction().getReadVersion().get())) {
|
||||
Key zone_key = healthyZone.first.withPrefix(prefix);
|
||||
int64_t seconds = healthyZone.first == ignoreSSFailuresZoneString
|
||||
double seconds = healthyZone.first == ignoreSSFailuresZoneString
|
||||
? 0
|
||||
: (healthyZone.second - ryw->getTransaction().getReadVersion().get()) /
|
||||
CLIENT_KNOBS->CORE_VERSIONSPERSECOND;
|
||||
@ -1965,7 +1965,7 @@ ACTOR static Future<Optional<std::string>> maintenanceCommitActor(ReadYourWrites
|
||||
state RangeMap<Key, std::pair<bool, Optional<Value>>, KeyRangeRef>::Ranges ranges =
|
||||
ryw->getSpecialKeySpaceWriteMap().containedRanges(kr);
|
||||
Key zoneId;
|
||||
int64_t seconds;
|
||||
double seconds;
|
||||
bool isSet = false;
|
||||
// Since maintenance only allows one zone at the same time,
|
||||
// if a transaction has more than one set operation on different zone keys,
|
||||
@ -1979,7 +1979,7 @@ ACTOR static Future<Optional<std::string>> maintenanceCommitActor(ReadYourWrites
|
||||
false, "maintenance", "Multiple zones given for maintenance, only one allowed at the same time"));
|
||||
isSet = true;
|
||||
zoneId = iter->begin().removePrefix(kr.begin);
|
||||
seconds = boost::lexical_cast<int64_t>(iter->value().second.get().toString());
|
||||
seconds = boost::lexical_cast<double>(iter->value().second.get().toString());
|
||||
} else {
|
||||
// if we already have set operation, then all clear operations will be meaningless, thus skip
|
||||
if (!isSet && healthyZone.present() && iter.range().contains(healthyZone.get().first.withPrefix(kr.begin)))
|
||||
@ -1992,6 +1992,10 @@ ACTOR static Future<Optional<std::string>> maintenanceCommitActor(ReadYourWrites
|
||||
std::string msg = "Maintenance mode cannot be used while data distribution is disabled for storage "
|
||||
"server failures.";
|
||||
return Optional<std::string>(ManagementAPIError::toJsonString(false, "maintenance", msg));
|
||||
} else if (seconds <= 0) {
|
||||
std::string msg = "The specified maintenance time " + boost::lexical_cast<std::string>(seconds) +
|
||||
" is not a positive value";
|
||||
return Optional<std::string>(ManagementAPIError::toJsonString(false, "maintenance", msg));
|
||||
} else {
|
||||
TraceEvent(SevDebug, "SKSMaintenanceSet").detail("ZoneId", zoneId.toString());
|
||||
ryw->getTransaction().set(healthyZoneKey,
|
||||
|
Loading…
x
Reference in New Issue
Block a user