Skip to content

Commit

Permalink
Test hypothesis 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszeszko-meta committed Mar 10, 2025
1 parent 9807d06 commit 7202178
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
38 changes: 24 additions & 14 deletions db/wal_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <algorithm>
#include <cinttypes>
#include <memory>
#include <thread>
#include <vector>

#include "db/log_reader.h"
Expand Down Expand Up @@ -172,8 +173,9 @@ void WalManager::PurgeObsoleteWALFiles() {
s = env_->GetChildren(archival_dir, &files);
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_ERROR(db_options_.info_log, "Can't get archive files: %s",
s.ToString().c_str());
ROCKS_LOG_ERROR(
db_options_.info_log, "Can't get archive files: %s, Thread id: %lu",
s.ToString().c_str(), (unsigned long)pthread_self());
return;
}

Expand All @@ -190,17 +192,20 @@ void WalManager::PurgeObsoleteWALFiles() {
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_WARN(db_options_.info_log,
"Can't get file mod time: %s: %s", file_path.c_str(),
s.ToString().c_str());
"Can't get file mod time: %s: %s, Thread id: %lu",
file_path.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
continue;
}
if (now_seconds - file_m_time > db_options_.WAL_ttl_seconds) {
s = DeleteDBFile(&db_options_, file_path, archival_dir, false,
/*force_fg=*/!wal_in_db_path_);
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_WARN(db_options_.info_log, "Can't delete file: %s: %s",
file_path.c_str(), s.ToString().c_str());
ROCKS_LOG_WARN(db_options_.info_log,
"Can't delete file: %s: %s, Thread id: %lu",
file_path.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
continue;
} else {
MutexLock l(&read_first_record_cache_mutex_);
Expand All @@ -216,8 +221,9 @@ void WalManager::PurgeObsoleteWALFiles() {
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_ERROR(db_options_.info_log,
"Unable to get file size: %s: %s", file_path.c_str(),
s.ToString().c_str());
"Unable to get file size: %s: %s, , Thread id: %lu",
file_path.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
return;
} else {
if (file_size > 0) {
Expand All @@ -229,8 +235,9 @@ void WalManager::PurgeObsoleteWALFiles() {
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_WARN(db_options_.info_log,
"Unable to delete file: %s: %s", file_path.c_str(),
s.ToString().c_str());
"Unable to delete file: %s: %s, Thread id: %lu",
file_path.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
continue;
} else {
MutexLock l(&read_first_record_cache_mutex_);
Expand Down Expand Up @@ -259,8 +266,9 @@ void WalManager::PurgeObsoleteWALFiles() {
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_WARN(db_options_.info_log,
"Unable to get archived WALs from: %s: %s",
archival_dir.c_str(), s.ToString().c_str());
"Unable to get archived WALs from: %s: %s, Thread id: %lu",
archival_dir.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
files_del_num = 0;
} else if (files_del_num > archived_logs.size()) {
ROCKS_LOG_WARN(db_options_.info_log,
Expand All @@ -275,8 +283,10 @@ void WalManager::PurgeObsoleteWALFiles() {
/*force_fg=*/!wal_in_db_path_);
if (!s.ok()) {
IGNORE_STATUS_IF_ERROR(s);
ROCKS_LOG_WARN(db_options_.info_log, "Unable to delete file: %s: %s",
file_path.c_str(), s.ToString().c_str());
ROCKS_LOG_WARN(db_options_.info_log,
"Unable to delete file: %s: %s, Thread id: %lu",
file_path.c_str(), s.ToString().c_str(),
(unsigned long)pthread_self());
continue;
} else {
MutexLock l(&read_first_record_cache_mutex_);
Expand Down
5 changes: 4 additions & 1 deletion db_stress_tool/db_stress_shared_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ class SharedState {
}

private:
static void IgnoreReadErrorCallback(void*) { ignore_read_error = true; }
static void IgnoreReadErrorCallback(void*) {
fprintf(stdout, "DBStress thread id: %lu\n", (unsigned long)pthread_self());
ignore_read_error = true;
}

// Pick random keys in each column family that will not experience overwrite.
std::unordered_set<int64_t> GenerateNoOverwriteIds() const {
Expand Down
6 changes: 2 additions & 4 deletions db_stress_tool/no_batched_ops_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1685,10 +1685,6 @@ class NonBatchedOpsStressTest : public StressTest {
s = iter->status();
}

if (ro_copy.auto_refresh_iterator_with_snapshot) {
std::this_thread::sleep_for(std::chrono::microseconds(3 * 1000 * 1000));
}

int injected_error_count = 0;
if (fault_fs_guard) {
injected_error_count = GetMinInjectedErrorCount(
Expand All @@ -1701,6 +1697,8 @@ class NonBatchedOpsStressTest : public StressTest {
// Grab mutex so multiple thread don't try to print the
// stack trace at the same time
MutexLock l(thread->shared->GetMutex());
fprintf(stderr, "DBStress thread id: %lu\n",
(unsigned long)pthread_self());
fprintf(stderr, "Didn't get expected error from PrefixScan\n");
fprintf(stderr, "Callstack that injected the fault\n");
fault_fs_guard->PrintInjectedThreadLocalErrorBacktrace(
Expand Down

0 comments on commit 7202178

Please sign in to comment.