Enable range clear in special key space

This commit is contained in:
Chaoguang Lin 2020-07-06 12:11:01 -07:00
parent 784d0f6d00
commit 38e2310530
4 changed files with 24 additions and 15 deletions

View File

@ -1812,12 +1812,11 @@ void ReadYourWritesTransaction::clear( const KeyRangeRef& range ) {
throw used_during_commit(); throw used_during_commit();
} }
// TODO : enable later if (specialKeys.contains(range)) {
// if (specialKeys.contains(range)) { if (getDatabase()->apiVersionAtLeast(700)) {
// if (getDatabase()->apiVersionAtLeast(700)) { return getDatabase()->specialKeySpace->clear(this, range);
// return getDatabase()->specialKeySpace->clear(this, range); }
// } }
// }
KeyRef maxKey = getMaxWriteKey(); KeyRef maxKey = getMaxWriteKey();
if(range.begin > maxKey || range.end > maxKey) if(range.begin > maxKey || range.end > maxKey)

View File

@ -622,9 +622,8 @@ ACTOR Future<bool> checkExclusion(Database db, std::vector<AddressExclusion>* ad
if (ssExcludedCount == ssTotalCount || if (ssExcludedCount == ssTotalCount ||
(1 - worstFreeSpaceRatio) * ssTotalCount / (ssTotalCount - ssExcludedCount) > 0.9) { (1 - worstFreeSpaceRatio) * ssTotalCount / (ssTotalCount - ssExcludedCount) > 0.9) {
msg = msg = "ERROR: This exclude may cause the total free space in the cluster to drop below 10%%.\nType `exclude "
"ERROR: This exclude may cause the total free space in the cluster to drop below 10%%.\n" "FORCE <ADDRESS...>' to exclude without checking free space.\n"; // TODO : update message here
"Type `exclude FORCE <ADDRESS...>' to exclude without checking free space.\n"; // TODO : update message here
return false; return false;
} }
return true; return true;
@ -654,8 +653,8 @@ ACTOR Future<Optional<std::string>> excludeCommitActor(ReadYourWritesTransaction
state std::vector<AddressExclusion> addresses; state std::vector<AddressExclusion> addresses;
state std::set<AddressExclusion> exclusions; state std::set<AddressExclusion> exclusions;
TraceEvent(SevInfo, "SKSExclude").detail("ExcludeCommitStart", ""); TraceEvent(SevInfo, "SKSExclude").detail("ExcludeCommitStart", "");
if (!parseNetWorkAddrFromKeys(ryw, excludedServersKeys.withPrefix(normalKeys.end), addresses, exclusions, result)) return result; if (!parseNetWorkAddrFromKeys(ryw, excludedServersKeys.withPrefix(normalKeys.end), addresses, exclusions, result))
// TODO : all checks before exclude return result;
TraceEvent(SevInfo, "SKSExclude").detail("ExcludeSafetyCheckStart", ""); TraceEvent(SevInfo, "SKSExclude").detail("ExcludeSafetyCheckStart", "");
bool safe = wait(checkExclusion(ryw->getDatabase(), &addresses, &exclusions, false, result)); bool safe = wait(checkExclusion(ryw->getDatabase(), &addresses, &exclusions, false, result));
if (!safe) return result; if (!safe) return result;

View File

@ -150,14 +150,23 @@ public:
Future<Void> commit(ReadYourWritesTransaction* ryw); Future<Void> commit(ReadYourWritesTransaction* ryw);
void set(ReadYourWritesTransaction* ryw, const KeyRef& key, const ValueRef& value) { void set(ReadYourWritesTransaction* ryw, const KeyRef& key, const ValueRef& value) {
// TODO : check value valid
auto impl = writeImpls[key]; auto impl = writeImpls[key];
if (impl == nullptr) throw special_keys_no_module_found(); // TODO : change the error type here // TODO : do we need the separate error here to differentiate from read?
if (impl == nullptr) throw special_keys_no_write_module_found();
return impl->set(ryw, key, value); return impl->set(ryw, key, value);
} }
// void clear(ReadYourWritesTransaction* ryw, const KeyRangeRef& range ); // TODO : ban cross module clear void clear(ReadYourWritesTransaction* ryw, const KeyRangeRef& range ) {
if (range.empty()) return;
auto begin = writeImpls[range.begin];
auto end = writeImpls[range.end];
if (begin != end) throw special_keys_cross_module_clear(); // ban cross module clear
else if (begin == nullptr) throw special_keys_no_write_module_found();
return begin->clear(ryw, range);
}
void clear(ReadYourWritesTransaction* ryw, const KeyRef& key) { void clear(ReadYourWritesTransaction* ryw, const KeyRef& key) {
auto impl = writeImpls[key]; auto impl = writeImpls[key];
if (impl == nullptr) throw special_keys_no_module_found(); // TODO : change the error type here if (impl == nullptr) throw special_keys_no_write_module_found();
return impl->clear(ryw, key); return impl->clear(ryw, key);
} }
// TODO : do we need to move it to .cpp file // TODO : do we need to move it to .cpp file

View File

@ -156,7 +156,9 @@ ERROR( tag_too_long, 2110, "Tag set on transaction is too long" )
ERROR( too_many_tag_throttles, 2111, "Too many tag throttles have been created" ) ERROR( too_many_tag_throttles, 2111, "Too many tag throttles have been created" )
ERROR( special_keys_cross_module_read, 2112, "Special key space range read crosses modules. Refer to the `special_key_space_relaxed' transaction option for more details." ) ERROR( special_keys_cross_module_read, 2112, "Special key space range read crosses modules. Refer to the `special_key_space_relaxed' transaction option for more details." )
ERROR( special_keys_no_module_found, 2113, "Special key space range read does not intersect a module. Refer to the `special_key_space_relaxed' transaction option for more details." ) ERROR( special_keys_no_module_found, 2113, "Special key space range read does not intersect a module. Refer to the `special_key_space_relaxed' transaction option for more details." )
ERROR( special_keys_management_api_failure, 2114, "Management Api call through special keys failed. For more information, call get(\"\xff\xff/confg/failure\") to get a json string of the error message." ) ERROR( special_keys_no_write_module_found, 2114, "Special key space key or keyrange in set or clear does not intersect a module" )
ERROR( special_keys_cross_module_clear, 2115, "Special key space clear crosses modules" )
ERROR( special_keys_management_api_failure, 2116, "Management Api call through special keys failed. For more information, call get(\"\xff\xff/confg/failure\") to get a json string of the error message." )
// 2200 - errors from bindings and official APIs // 2200 - errors from bindings and official APIs
ERROR( api_version_unset, 2200, "API version is not set" ) ERROR( api_version_unset, 2200, "API version is not set" )