-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend the unicast based recovery algorithm to do replication policy check #11996
Open
sbodagala
wants to merge
1
commit into
apple:main
Choose a base branch
from
sbodagala:version-vector-revert-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1976,7 +1976,7 @@ ACTOR Future<Void> TagPartitionedLogSystem::monitorLog(Reference<AsyncVar<Option | |
} | ||
} | ||
|
||
Optional<std::tuple<Version, Version, std::vector<TLogLockResult>>> TagPartitionedLogSystem::getDurableVersion( | ||
Optional<std::tuple<Version, Version, std::vector<TLogLockResult>, bool>> TagPartitionedLogSystem::getDurableVersion( | ||
UID dbgid, | ||
LogLockInfo lockInfo, | ||
std::vector<Reference<AsyncVar<bool>>> failed, | ||
|
@@ -2014,18 +2014,9 @@ Optional<std::tuple<Version, Version, std::vector<TLogLockResult>>> TagPartition | |
bool bTooManyFailures = (results.size() <= logSet->tLogWriteAntiQuorum); | ||
|
||
// Check if failed logs complete the policy | ||
// @note Do not do the replication policy validation check if version vector | ||
// is enabled. The implication of this change is that recoveries could take | ||
// longer when version vector is enabled - that's fine for now as "version | ||
// vector" is an experimental feature at this point. | ||
// @todo Extend "getRecoverVersionUnicast()" (the function that finds the | ||
// recovery version when version vector is enabled) to do the replication | ||
// policy check in an efficient manner, and enable the validation check | ||
// here at that point. | ||
bool failedLogsCompletePolicy = unResponsiveSet.validate(logSet->tLogPolicy); | ||
bTooManyFailures = | ||
bTooManyFailures || | ||
((unResponsiveSet.size() >= logSet->tLogReplicationFactor) && | ||
(SERVER_KNOBS->ENABLE_VERSION_VECTOR_TLOG_UNICAST || (unResponsiveSet.validate(logSet->tLogPolicy)))); | ||
bTooManyFailures || ((unResponsiveSet.size() >= logSet->tLogReplicationFactor) && failedLogsCompletePolicy); | ||
|
||
// Check all combinations of the AntiQuorum within the failed | ||
if (!bTooManyFailures && (logSet->tLogWriteAntiQuorum) && | ||
|
@@ -2091,14 +2082,15 @@ Optional<std::tuple<Version, Version, std::vector<TLogLockResult>>> TagPartition | |
// as choosing any other version may result in not copying the correct version range to the | ||
// log servers in the latest epoch and also will invalidate the changes that we made to the | ||
// peek logic in the context of version vector. | ||
return std::make_tuple(knownCommittedVersion, results[new_safe_range_begin].end, results); | ||
return std::make_tuple( | ||
knownCommittedVersion, results[new_safe_range_begin].end, results, failedLogsCompletePolicy); | ||
} | ||
} | ||
TraceEvent("GetDurableResultWaiting", dbgid) | ||
.detail("Required", requiredCount) | ||
.detail("Present", results.size()) | ||
.detail("ServerState", sServerState); | ||
return Optional<std::tuple<Version, Version, std::vector<TLogLockResult>>>(); | ||
return Optional<std::tuple<Version, Version, std::vector<TLogLockResult>, bool>>(); | ||
} | ||
|
||
ACTOR Future<Void> TagPartitionedLogSystem::getDurableVersionChanged(LogLockInfo lockInfo, | ||
|
@@ -2121,7 +2113,7 @@ ACTOR Future<Void> TagPartitionedLogSystem::getDurableVersionChanged(LogLockInfo | |
} | ||
|
||
void getTLogLocIds(const std::vector<Reference<LogSet>>& tLogs, | ||
const std::tuple<int, std::vector<TLogLockResult>>& logGroupResults, | ||
const std::tuple<int, std::vector<TLogLockResult>, bool>& logGroupResults, | ||
std::vector<uint16_t>& tLogLocIds, | ||
uint16_t& maxTLogLocId) { | ||
// Initialization. | ||
|
@@ -2153,7 +2145,7 @@ void getTLogLocIds(const std::vector<Reference<LogSet>>& tLogs, | |
} | ||
} | ||
|
||
Version findMaxKCV(const std::tuple<int, std::vector<TLogLockResult>>& logGroupResults) { | ||
Version findMaxKCV(const std::tuple<int, std::vector<TLogLockResult>, bool>& logGroupResults) { | ||
Version maxKCV = 0; | ||
for (auto& tLogResult : std::get<1>(logGroupResults)) { | ||
maxKCV = std::max(maxKCV, tLogResult.knownCommittedVersion); | ||
|
@@ -2174,7 +2166,7 @@ void populateBitset(boost::dynamic_bitset<>& bs, const std::vector<uint16_t>& id | |
// TODO: unit tests to stress UNICAST | ||
Optional<std::tuple<Version, Version>> getRecoverVersionUnicast( | ||
const std::vector<Reference<LogSet>>& logServers, | ||
const std::tuple<int, std::vector<TLogLockResult>>& logGroupResults, | ||
const std::tuple<int, std::vector<TLogLockResult>, bool>& logGroupResults, | ||
Version minDV) { | ||
std::vector<uint16_t> tLogLocIds; | ||
uint16_t maxTLogLocId; // maximum possible id, not maximum of id's of available log servers | ||
|
@@ -2239,6 +2231,7 @@ Optional<std::tuple<Version, Version>> getRecoverVersionUnicast( | |
// @note we currently don't use "RVs", but we may use this information later (maybe for | ||
// doing error checking). Commenting out the RVs related code for now. | ||
// std::vector<Version> RVs(maxTLogLocId + 1, maxKCV); // recovery versions of various tLogs | ||
bool nonAvailableTLogsCompletePolicy = std::get<2>(logGroupResults); | ||
Version prevVersion = maxKCV; | ||
for (auto const& [version, tLogs] : versionAllTLogs) { | ||
if (!(prevVersion == maxKCV || prevVersion == prevVersionMap[version])) { | ||
|
@@ -2252,10 +2245,18 @@ Optional<std::tuple<Version, Version>> getRecoverVersionUnicast( | |
break; | ||
} | ||
// If the commit proxy sent this version to "N" log servers then at least | ||
// (N - replicationFactor + 1) log servers must be available. | ||
// @todo Also do the replication policy validation check here, and enable | ||
// that check in "getDurableVersion()" at that point. | ||
if (!(versionAvailableTLogs[version].count() >= tLogs.count() - replicationFactor + 1)) { | ||
// (N - replicationFactor + 1) log servers must be available, or the set | ||
// of nonavailable log servers doesn't complete the replication policy. | ||
// @note The replication policy check we do here is more restrictive than | ||
// what it needs to be - it is checking whether the entire nonavailable log | ||
// server set (and not whether the nonavailable log servers from among the | ||
// set of log servers that the version was sent to) meets the replication | ||
// policy. We are doing it this way as checking it this way is more efficient | ||
// than checking on an individual version basis (which would require us to | ||
// build the nonavailable log server set for each version in the unavaialble | ||
// version list). | ||
if (!((versionAvailableTLogs[version].count() >= tLogs.count() - replicationFactor + 1) || | ||
!nonAvailableTLogsCompletePolicy)) { | ||
break; | ||
} | ||
// Update RV. | ||
|
@@ -2538,15 +2539,16 @@ ACTOR Future<Void> TagPartitionedLogSystem::epochEnd(Reference<AsyncVar<Referenc | |
Version minDV = std::numeric_limits<Version>::max(); | ||
Version maxEnd = 0; | ||
state std::vector<Future<Void>> changes; | ||
state std::vector<std::tuple<int, std::vector<TLogLockResult>>> logGroupResults; | ||
state std::vector<std::tuple<int, std::vector<TLogLockResult>, bool>> logGroupResults; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tuple has become hard to read. Can it be made into a structure instead? I think it would improve the code. |
||
for (int log = 0; log < logServers.size(); log++) { | ||
if (!logServers[log]->isLocal) { | ||
continue; | ||
} | ||
auto versions = | ||
TagPartitionedLogSystem::getDurableVersion(dbgid, lockResults[log], logFailed[log], lastEnd); | ||
if (versions.present()) { | ||
logGroupResults.emplace_back(logServers[log]->tLogReplicationFactor, std::get<2>(versions.get())); | ||
logGroupResults.emplace_back( | ||
logServers[log]->tLogReplicationFactor, std::get<2>(versions.get()), std::get<3>(versions.get())); | ||
minDV = std::min(minDV, std::get<1>(versions.get())); | ||
if (!SERVER_KNOBS->ENABLE_VERSION_VECTOR_TLOG_UNICAST) { | ||
knownCommittedVersion = std::max(knownCommittedVersion, std::get<0>(versions.get())); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is a little hard to follow. Maybe something more like this?
// At least (N - replicationFactor + 1) log servers must be available.
// Otherwise, the unavailable log servers alone would not be sufficient
// to satisfy the replication policy.
//
// @note This check is intentionally more restrictive than necessary.
// Instead of verifying whether the unavailable log servers within
// the specific set that received the version satisfy the replication policy,
// we check whether the entire set of unavailable log servers meets the policy.
//
// This approach is chosen because it is computationally more efficient.
// Checking availability on a per-version basis would require constructing
// a unique set of unavailable log servers for each version in the unavailable
// version list, which would add significant overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the comment. Thanks for the edit!