-
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
Add BitFlip fault injection workload #11264
Draft
jzhou77
wants to merge
8
commits into
apple:main
Choose a base branch
from
jzhou77:main
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.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5b9c291
Remove wrong comments
jzhou77 c588f69
Add BitFlip fault injection workload
jzhou77 7205707
Merge remote-tracking branch 'refs/remotes/apple/main'
jzhou77 047bd9c
Only inject bit flip once at each location
jzhou77 0921e3a
Only enable bit flip when accumulative checksum is on
jzhou77 bbc0a22
Enable checksum knobs by default
jzhou77 84e9e03
Change checksum trace event severity
jzhou77 7a505bd
Merge branch 'main' of https://github.com/apple/foundationdb
jzhou77 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* BitFlip.actor.cpp | ||
* | ||
* This source file is part of the FoundationDB open source project | ||
* | ||
* Copyright 2013-2024 Apple Inc. and the FoundationDB project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "fdbclient/Knobs.h" | ||
#include "fdbrpc/simulator.h" | ||
#include "fdbserver/TesterInterface.actor.h" | ||
#include "fdbserver/QuietDatabase.h" | ||
#include "fdbserver/ServerDBInfo.h" | ||
#include "fdbserver/workloads/workloads.actor.h" | ||
#include "flow/DeterministicRandom.h" | ||
|
||
#include "flow/actorcompiler.h" // This must be the last #include. | ||
|
||
// A simulation workload that flips random memory bit of the data in the system. | ||
struct BitFlipWorkload : FailureInjectionWorkload { | ||
static constexpr auto NAME = "BitFlip"; | ||
bool enabled; | ||
bool success = true; | ||
|
||
// How long to run the workload before starting | ||
double initialDelay = 0.0; | ||
|
||
// How long the workload should be run; if <= 0 then it will run until the workload's check function is called | ||
double duration = 10.0; | ||
|
||
BitFlipWorkload(WorkloadContext const& wcx, NoOptions) : FailureInjectionWorkload(wcx) { | ||
enabled = !clientId && g_network->isSimulated() && CLIENT_KNOBS->ENABLE_ACCUMULATIVE_CHECKSUM && | ||
CLIENT_KNOBS->ENABLE_MUTATION_CHECKSUM; | ||
} | ||
|
||
BitFlipWorkload(WorkloadContext const& wcx) : FailureInjectionWorkload(wcx) { | ||
// only do this on the "first" client in simulation | ||
enabled = !clientId && g_network->isSimulated() && CLIENT_KNOBS->ENABLE_ACCUMULATIVE_CHECKSUM && | ||
CLIENT_KNOBS->ENABLE_MUTATION_CHECKSUM; | ||
initialDelay = getOption(options, "initialDelay"_sr, 0.0); | ||
duration = getOption(options, "testDuration"_sr, 20.0); | ||
} | ||
|
||
bool shouldInject(DeterministicRandom& random, | ||
const WorkloadRequest& work, | ||
const unsigned alreadyAdded) const override { | ||
return alreadyAdded < 1 && work.useDatabase && 0.1 / (1 + alreadyAdded) > random.random01(); | ||
} | ||
Future<Void> setup(Database const& cx) override { return Void(); } | ||
|
||
Future<Void> start(Database const& cx) override { return _start(cx, this); } | ||
|
||
ACTOR Future<Void> _start(Database cx, BitFlipWorkload* self) { | ||
if (!self->enabled) { | ||
return Void(); | ||
} | ||
|
||
wait(delay(self->initialDelay)); | ||
TraceEvent("BitFlipOn").log(); | ||
g_simulator->enableBitFlipInjection(); | ||
|
||
// If a duration was given, let the duration elapse and then shut the profiler off | ||
if (self->duration > 0) { | ||
wait(delay(self->duration)); | ||
} | ||
g_simulator->disableBitFlipInjection(); | ||
TraceEvent("BitFlipOff").log(); | ||
|
||
return Void(); | ||
} | ||
|
||
Future<bool> check(Database const& cx) override { return success; } | ||
|
||
void getMetrics(std::vector<PerfMetric>& m) override {} | ||
}; | ||
|
||
WorkloadFactory<BitFlipWorkload> BitFlipWorkloadFactory; | ||
FailureInjectorFactory<BitFlipWorkload> BitFlipFailureInjectorFactory; |
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.
Open this assert when running