2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2014-11-20 18:49:32 +00:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <condition_variable>
|
|
|
|
|
2017-04-06 02:02:00 +00:00
|
|
|
#include "monitoring/thread_status_updater.h"
|
2014-11-20 18:49:32 +00:00
|
|
|
#include "rocksdb/db.h"
|
2019-05-30 18:21:38 +00:00
|
|
|
#include "test_util/testharness.h"
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2016-12-14 02:22:00 +00:00
|
|
|
#ifdef ROCKSDB_USING_THREAD_STATUS
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
class SimulatedBackgroundTask {
|
2014-11-20 18:49:32 +00:00
|
|
|
public:
|
2014-12-30 18:39:13 +00:00
|
|
|
SimulatedBackgroundTask(
|
|
|
|
const void* db_key, const std::string& db_name,
|
|
|
|
const void* cf_key, const std::string& cf_name,
|
|
|
|
const ThreadStatus::OperationType operation_type =
|
|
|
|
ThreadStatus::OP_UNKNOWN,
|
|
|
|
const ThreadStatus::StateType state_type =
|
|
|
|
ThreadStatus::STATE_UNKNOWN)
|
2014-11-20 18:49:32 +00:00
|
|
|
: db_key_(db_key), db_name_(db_name),
|
|
|
|
cf_key_(cf_key), cf_name_(cf_name),
|
2014-12-30 18:39:13 +00:00
|
|
|
operation_type_(operation_type), state_type_(state_type),
|
|
|
|
should_run_(true), running_count_(0) {
|
2014-12-22 20:20:17 +00:00
|
|
|
Env::Default()->GetThreadStatusUpdater()->NewColumnFamilyInfo(
|
2014-11-20 18:49:32 +00:00
|
|
|
db_key_, db_name_, cf_key_, cf_name_);
|
|
|
|
}
|
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
~SimulatedBackgroundTask() {
|
2014-12-22 20:20:17 +00:00
|
|
|
Env::Default()->GetThreadStatusUpdater()->EraseDatabaseInfo(db_key_);
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
void Run() {
|
2014-11-20 18:49:32 +00:00
|
|
|
std::unique_lock<std::mutex> l(mutex_);
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count_++;
|
2021-01-04 18:45:15 +00:00
|
|
|
bg_cv_.notify_all();
|
2014-12-30 18:39:13 +00:00
|
|
|
Env::Default()->GetThreadStatusUpdater()->SetColumnFamilyInfoKey(cf_key_);
|
|
|
|
Env::Default()->GetThreadStatusUpdater()->SetThreadOperation(
|
|
|
|
operation_type_);
|
|
|
|
Env::Default()->GetThreadStatusUpdater()->SetThreadState(state_type_);
|
|
|
|
while (should_run_) {
|
2014-11-20 18:49:32 +00:00
|
|
|
bg_cv_.wait(l);
|
|
|
|
}
|
2014-12-30 18:39:13 +00:00
|
|
|
Env::Default()->GetThreadStatusUpdater()->ClearThreadState();
|
|
|
|
Env::Default()->GetThreadStatusUpdater()->ClearThreadOperation();
|
2018-03-07 20:39:19 +00:00
|
|
|
Env::Default()->GetThreadStatusUpdater()->SetColumnFamilyInfoKey(nullptr);
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count_--;
|
|
|
|
bg_cv_.notify_all();
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
2014-12-30 18:39:13 +00:00
|
|
|
|
|
|
|
void FinishAllTasks() {
|
2014-11-20 18:49:32 +00:00
|
|
|
std::unique_lock<std::mutex> l(mutex_);
|
2014-12-30 18:39:13 +00:00
|
|
|
should_run_ = false;
|
2014-11-20 18:49:32 +00:00
|
|
|
bg_cv_.notify_all();
|
|
|
|
}
|
2014-12-30 18:39:13 +00:00
|
|
|
|
2021-01-04 18:45:15 +00:00
|
|
|
void WaitUntilScheduled(int job_count) {
|
|
|
|
std::unique_lock<std::mutex> l(mutex_);
|
2014-12-30 18:39:13 +00:00
|
|
|
while (running_count_ < job_count) {
|
2021-01-04 18:45:15 +00:00
|
|
|
bg_cv_.wait(l);
|
2014-12-30 18:39:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-20 18:49:32 +00:00
|
|
|
void WaitUntilDone() {
|
|
|
|
std::unique_lock<std::mutex> l(mutex_);
|
2014-12-30 18:39:13 +00:00
|
|
|
while (running_count_ > 0) {
|
2014-11-20 18:49:32 +00:00
|
|
|
bg_cv_.wait(l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
static void DoSimulatedTask(void* arg) {
|
|
|
|
reinterpret_cast<SimulatedBackgroundTask*>(arg)->Run();
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const void* db_key_;
|
|
|
|
const std::string db_name_;
|
|
|
|
const void* cf_key_;
|
|
|
|
const std::string cf_name_;
|
2014-12-30 18:39:13 +00:00
|
|
|
const ThreadStatus::OperationType operation_type_;
|
|
|
|
const ThreadStatus::StateType state_type_;
|
2014-11-20 18:49:32 +00:00
|
|
|
std::mutex mutex_;
|
|
|
|
std::condition_variable bg_cv_;
|
2014-12-30 18:39:13 +00:00
|
|
|
bool should_run_;
|
|
|
|
std::atomic<int> running_count_;
|
2014-11-20 18:49:32 +00:00
|
|
|
};
|
|
|
|
|
2015-03-17 21:08:00 +00:00
|
|
|
class ThreadListTest : public testing::Test {
|
2014-11-20 18:49:32 +00:00
|
|
|
public:
|
|
|
|
ThreadListTest() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-03-17 21:08:00 +00:00
|
|
|
TEST_F(ThreadListTest, GlobalTables) {
|
2014-12-30 18:39:13 +00:00
|
|
|
// verify the global tables for operations and states are properly indexed.
|
|
|
|
for (int type = 0; type != ThreadStatus::NUM_OP_TYPES; ++type) {
|
|
|
|
ASSERT_EQ(global_operation_table[type].type, type);
|
2015-02-04 09:47:32 +00:00
|
|
|
ASSERT_EQ(global_operation_table[type].name,
|
|
|
|
ThreadStatus::GetOperationName(
|
|
|
|
ThreadStatus::OperationType(type)));
|
2014-12-30 18:39:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int type = 0; type != ThreadStatus::NUM_STATE_TYPES; ++type) {
|
|
|
|
ASSERT_EQ(global_state_table[type].type, type);
|
2015-02-04 09:47:32 +00:00
|
|
|
ASSERT_EQ(global_state_table[type].name,
|
|
|
|
ThreadStatus::GetStateName(
|
|
|
|
ThreadStatus::StateType(type)));
|
2014-12-30 18:39:13 +00:00
|
|
|
}
|
2015-03-13 17:45:40 +00:00
|
|
|
|
|
|
|
for (int stage = 0; stage != ThreadStatus::NUM_OP_STAGES; ++stage) {
|
|
|
|
ASSERT_EQ(global_op_stage_table[stage].stage, stage);
|
|
|
|
ASSERT_EQ(global_op_stage_table[stage].name,
|
|
|
|
ThreadStatus::GetOperationStageName(
|
|
|
|
ThreadStatus::OperationStage(stage)));
|
|
|
|
}
|
2014-12-30 18:39:13 +00:00
|
|
|
}
|
|
|
|
|
2015-03-17 21:08:00 +00:00
|
|
|
TEST_F(ThreadListTest, SimpleColumnFamilyInfoTest) {
|
2014-11-20 18:49:32 +00:00
|
|
|
Env* env = Env::Default();
|
|
|
|
const int kHighPriorityThreads = 3;
|
|
|
|
const int kLowPriorityThreads = 5;
|
2014-12-30 18:39:13 +00:00
|
|
|
const int kSimulatedHighPriThreads = kHighPriorityThreads - 1;
|
|
|
|
const int kSimulatedLowPriThreads = kLowPriorityThreads / 3;
|
2022-07-09 02:48:09 +00:00
|
|
|
const int kDelayMicros = 1000000;
|
2014-11-20 18:49:32 +00:00
|
|
|
env->SetBackgroundThreads(kHighPriorityThreads, Env::HIGH);
|
|
|
|
env->SetBackgroundThreads(kLowPriorityThreads, Env::LOW);
|
2022-07-09 02:48:09 +00:00
|
|
|
// Wait 1 second so that threads start
|
|
|
|
Env::Default()->SleepForMicroseconds(kDelayMicros);
|
2014-12-30 18:39:13 +00:00
|
|
|
SimulatedBackgroundTask running_task(
|
|
|
|
reinterpret_cast<void*>(1234), "running",
|
2014-11-20 18:49:32 +00:00
|
|
|
reinterpret_cast<void*>(5678), "pikachu");
|
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
for (int test = 0; test < kSimulatedHighPriThreads; ++test) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&running_task, Env::Priority::HIGH);
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
2022-07-09 02:48:09 +00:00
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
for (int test = 0; test < kSimulatedLowPriThreads; ++test) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&running_task, Env::Priority::LOW);
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
2021-01-04 18:45:15 +00:00
|
|
|
running_task.WaitUntilScheduled(kSimulatedHighPriThreads +
|
|
|
|
kSimulatedLowPriThreads);
|
2022-07-09 02:48:09 +00:00
|
|
|
// We can only reserve limited number of waiting threads
|
|
|
|
ASSERT_EQ(kHighPriorityThreads - kSimulatedHighPriThreads,
|
|
|
|
env->ReserveThreads(kHighPriorityThreads, Env::Priority::HIGH));
|
|
|
|
ASSERT_EQ(kLowPriorityThreads - kSimulatedLowPriThreads,
|
|
|
|
env->ReserveThreads(kLowPriorityThreads, Env::Priority::LOW));
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2022-07-09 02:48:09 +00:00
|
|
|
// Reservation shall not affect the existing thread list
|
2014-11-20 18:49:32 +00:00
|
|
|
std::vector<ThreadStatus> thread_list;
|
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
// Verify the number of running threads in each pool.
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
int running_count[ThreadStatus::NUM_THREAD_TYPES] = {0};
|
2014-11-20 18:49:32 +00:00
|
|
|
for (auto thread_status : thread_list) {
|
|
|
|
if (thread_status.cf_name == "pikachu" &&
|
2014-12-30 18:39:13 +00:00
|
|
|
thread_status.db_name == "running") {
|
|
|
|
running_count[thread_status.thread_type]++;
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-09 02:48:09 +00:00
|
|
|
// Cannot reserve more threads
|
|
|
|
ASSERT_EQ(0, env->ReserveThreads(kHighPriorityThreads, Env::Priority::HIGH));
|
|
|
|
ASSERT_EQ(0, env->ReserveThreads(kLowPriorityThreads, Env::Priority::LOW));
|
|
|
|
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::HIGH_PRIORITY],
|
|
|
|
kSimulatedHighPriThreads);
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::LOW_PRIORITY],
|
|
|
|
kSimulatedLowPriThreads);
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::USER], 0);
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
running_task.FinishAllTasks();
|
|
|
|
running_task.WaitUntilDone();
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2022-07-09 02:48:09 +00:00
|
|
|
ASSERT_EQ(kHighPriorityThreads - kSimulatedHighPriThreads,
|
|
|
|
env->ReleaseThreads(kHighPriorityThreads, Env::Priority::HIGH));
|
|
|
|
ASSERT_EQ(kLowPriorityThreads - kSimulatedLowPriThreads,
|
|
|
|
env->ReleaseThreads(kLowPriorityThreads, Env::Priority::LOW));
|
2014-12-30 18:39:13 +00:00
|
|
|
// Verify none of the threads are running
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-11-20 18:49:32 +00:00
|
|
|
|
2014-12-30 18:39:13 +00:00
|
|
|
for (int i = 0; i < ThreadStatus::NUM_THREAD_TYPES; ++i) {
|
|
|
|
running_count[i] = 0;
|
|
|
|
}
|
2014-11-20 18:49:32 +00:00
|
|
|
for (auto thread_status : thread_list) {
|
|
|
|
if (thread_status.cf_name == "pikachu" &&
|
2014-12-30 18:39:13 +00:00
|
|
|
thread_status.db_name == "running") {
|
|
|
|
running_count[thread_status.thread_type]++;
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-30 18:39:13 +00:00
|
|
|
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::HIGH_PRIORITY], 0);
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::LOW_PRIORITY], 0);
|
2014-11-20 18:49:32 +00:00
|
|
|
ASSERT_EQ(
|
2014-12-30 18:39:13 +00:00
|
|
|
running_count[ThreadStatus::USER], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
void UpdateStatusCounts(
|
|
|
|
const std::vector<ThreadStatus>& thread_list,
|
|
|
|
int operation_counts[], int state_counts[]) {
|
|
|
|
for (auto thread_status : thread_list) {
|
|
|
|
operation_counts[thread_status.operation_type]++;
|
|
|
|
state_counts[thread_status.state_type]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerifyAndResetCounts(
|
|
|
|
const int correct_counts[], int collected_counts[], int size) {
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
ASSERT_EQ(collected_counts[i], correct_counts[i]);
|
|
|
|
collected_counts[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateCount(
|
|
|
|
int operation_counts[], int from_event, int to_event, int amount) {
|
|
|
|
operation_counts[from_event] -= amount;
|
|
|
|
operation_counts[to_event] += amount;
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
2015-03-17 21:08:00 +00:00
|
|
|
TEST_F(ThreadListTest, SimpleEventTest) {
|
2014-12-30 18:39:13 +00:00
|
|
|
Env* env = Env::Default();
|
|
|
|
|
|
|
|
// simulated tasks
|
|
|
|
const int kFlushWriteTasks = 3;
|
|
|
|
SimulatedBackgroundTask flush_write_task(
|
|
|
|
reinterpret_cast<void*>(1234), "running",
|
|
|
|
reinterpret_cast<void*>(5678), "pikachu",
|
|
|
|
ThreadStatus::OP_FLUSH);
|
|
|
|
|
|
|
|
const int kCompactionWriteTasks = 4;
|
|
|
|
SimulatedBackgroundTask compaction_write_task(
|
|
|
|
reinterpret_cast<void*>(1234), "running",
|
|
|
|
reinterpret_cast<void*>(5678), "pikachu",
|
|
|
|
ThreadStatus::OP_COMPACTION);
|
|
|
|
|
|
|
|
const int kCompactionReadTasks = 5;
|
|
|
|
SimulatedBackgroundTask compaction_read_task(
|
|
|
|
reinterpret_cast<void*>(1234), "running",
|
|
|
|
reinterpret_cast<void*>(5678), "pikachu",
|
|
|
|
ThreadStatus::OP_COMPACTION);
|
|
|
|
|
|
|
|
const int kCompactionWaitTasks = 6;
|
|
|
|
SimulatedBackgroundTask compaction_wait_task(
|
|
|
|
reinterpret_cast<void*>(1234), "running",
|
|
|
|
reinterpret_cast<void*>(5678), "pikachu",
|
|
|
|
ThreadStatus::OP_COMPACTION);
|
|
|
|
|
|
|
|
// setup right answers
|
|
|
|
int correct_operation_counts[ThreadStatus::NUM_OP_TYPES] = {0};
|
|
|
|
correct_operation_counts[ThreadStatus::OP_FLUSH] =
|
|
|
|
kFlushWriteTasks;
|
|
|
|
correct_operation_counts[ThreadStatus::OP_COMPACTION] =
|
|
|
|
kCompactionWriteTasks + kCompactionReadTasks + kCompactionWaitTasks;
|
|
|
|
|
|
|
|
env->SetBackgroundThreads(
|
|
|
|
correct_operation_counts[ThreadStatus::OP_FLUSH], Env::HIGH);
|
|
|
|
env->SetBackgroundThreads(
|
|
|
|
correct_operation_counts[ThreadStatus::OP_COMPACTION], Env::LOW);
|
|
|
|
|
|
|
|
// schedule the simulated tasks
|
|
|
|
for (int t = 0; t < kFlushWriteTasks; ++t) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&flush_write_task, Env::Priority::HIGH);
|
|
|
|
}
|
2021-01-04 18:45:15 +00:00
|
|
|
flush_write_task.WaitUntilScheduled(kFlushWriteTasks);
|
2014-12-30 18:39:13 +00:00
|
|
|
|
|
|
|
for (int t = 0; t < kCompactionWriteTasks; ++t) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&compaction_write_task, Env::Priority::LOW);
|
|
|
|
}
|
2021-01-04 18:45:15 +00:00
|
|
|
compaction_write_task.WaitUntilScheduled(kCompactionWriteTasks);
|
2014-12-30 18:39:13 +00:00
|
|
|
|
|
|
|
for (int t = 0; t < kCompactionReadTasks; ++t) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&compaction_read_task, Env::Priority::LOW);
|
|
|
|
}
|
2021-01-04 18:45:15 +00:00
|
|
|
compaction_read_task.WaitUntilScheduled(kCompactionReadTasks);
|
2014-12-30 18:39:13 +00:00
|
|
|
|
|
|
|
for (int t = 0; t < kCompactionWaitTasks; ++t) {
|
|
|
|
env->Schedule(&SimulatedBackgroundTask::DoSimulatedTask,
|
|
|
|
&compaction_wait_task, Env::Priority::LOW);
|
|
|
|
}
|
2021-01-04 18:45:15 +00:00
|
|
|
compaction_wait_task.WaitUntilScheduled(kCompactionWaitTasks);
|
2014-12-30 18:39:13 +00:00
|
|
|
|
|
|
|
// verify the thread-status
|
|
|
|
int operation_counts[ThreadStatus::NUM_OP_TYPES] = {0};
|
|
|
|
int state_counts[ThreadStatus::NUM_STATE_TYPES] = {0};
|
|
|
|
|
|
|
|
std::vector<ThreadStatus> thread_list;
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
UpdateStatusCounts(thread_list, operation_counts, state_counts);
|
|
|
|
VerifyAndResetCounts(correct_operation_counts, operation_counts,
|
|
|
|
ThreadStatus::NUM_OP_TYPES);
|
|
|
|
|
|
|
|
// terminate compaction-wait tasks and see if the thread-status
|
|
|
|
// reflects this update
|
|
|
|
compaction_wait_task.FinishAllTasks();
|
|
|
|
compaction_wait_task.WaitUntilDone();
|
|
|
|
UpdateCount(correct_operation_counts, ThreadStatus::OP_COMPACTION,
|
|
|
|
ThreadStatus::OP_UNKNOWN, kCompactionWaitTasks);
|
|
|
|
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
UpdateStatusCounts(thread_list, operation_counts, state_counts);
|
|
|
|
VerifyAndResetCounts(correct_operation_counts, operation_counts,
|
|
|
|
ThreadStatus::NUM_OP_TYPES);
|
|
|
|
|
|
|
|
// terminate flush-write tasks and see if the thread-status
|
|
|
|
// reflects this update
|
|
|
|
flush_write_task.FinishAllTasks();
|
|
|
|
flush_write_task.WaitUntilDone();
|
|
|
|
UpdateCount(correct_operation_counts, ThreadStatus::OP_FLUSH,
|
|
|
|
ThreadStatus::OP_UNKNOWN, kFlushWriteTasks);
|
|
|
|
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
UpdateStatusCounts(thread_list, operation_counts, state_counts);
|
|
|
|
VerifyAndResetCounts(correct_operation_counts, operation_counts,
|
|
|
|
ThreadStatus::NUM_OP_TYPES);
|
|
|
|
|
|
|
|
// terminate compaction-write tasks and see if the thread-status
|
|
|
|
// reflects this update
|
|
|
|
compaction_write_task.FinishAllTasks();
|
|
|
|
compaction_write_task.WaitUntilDone();
|
|
|
|
UpdateCount(correct_operation_counts, ThreadStatus::OP_COMPACTION,
|
|
|
|
ThreadStatus::OP_UNKNOWN, kCompactionWriteTasks);
|
|
|
|
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
UpdateStatusCounts(thread_list, operation_counts, state_counts);
|
|
|
|
VerifyAndResetCounts(correct_operation_counts, operation_counts,
|
|
|
|
ThreadStatus::NUM_OP_TYPES);
|
|
|
|
|
|
|
|
// terminate compaction-write tasks and see if the thread-status
|
|
|
|
// reflects this update
|
|
|
|
compaction_read_task.FinishAllTasks();
|
|
|
|
compaction_read_task.WaitUntilDone();
|
|
|
|
UpdateCount(correct_operation_counts, ThreadStatus::OP_COMPACTION,
|
|
|
|
ThreadStatus::OP_UNKNOWN, kCompactionReadTasks);
|
|
|
|
|
2020-12-23 07:44:44 +00:00
|
|
|
ASSERT_OK(env->GetThreadList(&thread_list));
|
2014-12-30 18:39:13 +00:00
|
|
|
UpdateStatusCounts(thread_list, operation_counts, state_counts);
|
|
|
|
VerifyAndResetCounts(correct_operation_counts, operation_counts,
|
|
|
|
ThreadStatus::NUM_OP_TYPES);
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
2014-11-20 18:49:32 +00:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2022-10-18 07:35:35 +00:00
|
|
|
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
|
2015-03-17 21:08:00 +00:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
2014-11-20 18:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2015-03-17 21:08:00 +00:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
2014-11-20 18:49:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ROCKSDB_USING_THREAD_STATUS
|