Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc
index 851683244..fcde66af4 100644
--- a/db/db_impl_compaction_flush.cc
+++ b/db/db_impl_compaction_flush.cc
@@ -2013,6 +2013,9 @@ void DBImpl::BackgroundCallFlush() {
if (job_context.HaveSomethingToDelete()) {
PurgeObsoleteFiles(job_context);
}
+ static int f_count = 0;
+ printf("clean flush job context %d\n", ++f_count);
+ env_->SleepForMicroseconds(1000000);
job_context.Clean();
mutex_.Lock();
}
diff --git a/db/db_test.cc b/db/db_test.cc
index 85cb37050..46ed5edfe 100644
--- a/db/db_test.cc
+++ b/db/db_test.cc
@@ -5649,40 +5649,18 @@ TEST_F(DBTest, HardLimit) {
class WriteStallListener : public EventListener {
public:
WriteStallListener()
- : cond_(&mutex_),
- condition_(WriteStallCondition::kNormal),
- expected_(WriteStallCondition::kNormal),
- expected_set_(false) {}
+ : condition_(WriteStallCondition::kNormal) {}
void OnStallConditionsChanged(const WriteStallInfo& info) override {
MutexLock l(&mutex_);
condition_ = info.condition.cur;
- if (expected_set_ && condition_ == expected_) {
- cond_.Signal();
- expected_set_ = false;
- }
}
bool CheckCondition(WriteStallCondition expected) {
MutexLock l(&mutex_);
- if (expected != condition_) {
- expected_ = expected;
- expected_set_ = true;
- while (expected != condition_) {
- // We bail out on timeout 500 milliseconds
- const uint64_t timeout_us = 500000;
- if (cond_.TimedWait(timeout_us)) {
- expected_set_ = false;
- return false;
- }
- }
- }
- return true;
+ return expected == condition_;
}
private:
port::Mutex mutex_;
- port::CondVar cond_;
WriteStallCondition condition_;
- WriteStallCondition expected_;
- bool expected_set_;
};
TEST_F(DBTest, SoftLimit) {
@@ -5740,6 +5718,7 @@ TEST_F(DBTest, SoftLimit) {
// Flush the file. File size is around 30KB.
dbfull()->TEST_FlushMemTable(true, true);
}
+ printf("check state\n");
ASSERT_TRUE(dbfull()->TEST_write_controler().NeedsDelay());
ASSERT_TRUE(listener->CheckCondition(WriteStallCondition::kDelayed));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.