Skip to content
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

Add a router tag for all mutations after enabling HA [release-7.3] #11066

Draft
wants to merge 1 commit into
base: release-7.3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fdbclient/SystemData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ ProcessClass decodeProcessClassValue(ValueRef const& value) {

const KeyRangeRef configKeys("\xff/conf/"_sr, "\xff/conf0"_sr);
const KeyRef configKeysPrefix = configKeys.begin;

const KeyRef configUsableRegionsKey = "\xff/conf/usable_regions"_sr;
const KeyRef perpetualStorageWiggleKey("\xff/conf/perpetual_storage_wiggle"_sr);
const KeyRef perpetualStorageWiggleLocalityKey("\xff/conf/perpetual_storage_wiggle_locality"_sr);
// The below two are there for compatible upgrade and downgrade. After 7.3, the perpetual wiggle related keys should use
Expand Down
1 change: 1 addition & 0 deletions fdbclient/include/fdbclient/SystemData.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ UID decodeProcessClassKeyOld(KeyRef const& key);
// See DatabaseConfiguration.cpp ::setInternal for more examples.
extern const KeyRangeRef configKeys;
extern const KeyRef configKeysPrefix;
extern const KeyRef configUsableRegionsKey;

extern const KeyRef perpetualStorageWiggleKey;
extern const KeyRef perpetualStorageWiggleLocalityKey;
Expand Down
4 changes: 4 additions & 0 deletions fdbserver/ApplyMetadataMutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ class ApplyMetadataMutationsImpl {
.detail("ToCommit", toCommit != nullptr)
.detail("InitialCommit", initialCommit);
confChange = true;
if (m.param1 == configUsableRegionsKey && m.param2 == "2"_sr && toCommit) {
TraceEvent("MutationRequiresRestartEnableHA", dbgid);
toCommit->setChangedToHA();
}
}
}
if (!initialCommit)
Expand Down
2 changes: 2 additions & 0 deletions fdbserver/LogSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ void LogPushData::writeMessage(StringRef rawMessageWithoutLength, bool usePrevio
prev_tags.clear();
if (logSystem->hasRemoteLogs()) {
prev_tags.push_back(logSystem->getRandomRouterTag());
} else if (changedToHA) {
prev_tags.emplace_back(-2, 0);
}
for (auto& tag : next_message_tags) {
prev_tags.push_back(tag);
Expand Down
8 changes: 8 additions & 0 deletions fdbserver/include/fdbserver/LogSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,11 @@ struct LogPushData : NonCopyable {
// getAllMessages() and is used before writing any other mutations.
void setMutations(uint32_t totalMutations, VectorRef<StringRef> mutations);

// After HA is enabled, we always add log router tag (-2, 0) to all mutations
// to ensure after the recovery, the mutations can be sent to the log routers
// for the remote region to consume.
void setChangedToHA() { changedToHA = true; }

private:
Reference<ILogSystem> logSystem;
std::vector<Tag> next_message_tags;
Expand All @@ -828,6 +833,7 @@ struct LogPushData : NonCopyable {
uint32_t subsequence;
SpanContext spanContext;
bool shardChanged = false; // if keyServers has any changes, i.e., shard boundary modifications.
bool changedToHA = false; // if DB configuration usable_regions changed from 1 to 2

// Writes transaction info to the message stream at the given location if
// it has not already been written (for the current transaction). Returns
Expand All @@ -841,6 +847,8 @@ void LogPushData::writeTypedMessage(T const& item, bool metadataMessage, bool al
prev_tags.clear();
if (logSystem->hasRemoteLogs()) {
prev_tags.push_back(logSystem->getRandomRouterTag());
} else if (changedToHA) {
prev_tags.emplace_back(-2, 0);
}
for (auto& tag : next_message_tags) {
prev_tags.push_back(tag);
Expand Down