diff --git a/db/db_test.cc b/db/db_test.cc index 2fb6226f2..e0f3996be 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -8725,6 +8725,15 @@ class RecoveryTestHelper { test->dbname_ + "/" + wal_files.front()->PathName(); auto size = wal_files.front()->SizeFileBytes(); +#ifdef OS_WIN + // Windows disk cache behaves differently. When we truncate + // the original content is still in the cache due to the original + // handle is still open. Generally, in Windows, one prohibits + // shared access to files and it is not needed for WAL but we allow + // it to induce corruption at various tests. + test->Close(); +#endif + if (trunc) { ASSERT_EQ(0, truncate(logfile_path.c_str(), size * off)); } else { diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 27c5c3fbd..d29a63a6e 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -2405,7 +2405,7 @@ public: queue_.push_back(BGItem()); queue_.back().function = function; queue_.back().arg = arg; - queue_.back().arg = tag; + queue_.back().tag = tag; queue_len_.store(queue_.size(), std::memory_order_relaxed); if (!HasExcessiveThread()) { diff --git a/port/win/port_win.cc b/port/win/port_win.cc index 7e0b45cfd..0ea706c79 100644 --- a/port/win/port_win.cc +++ b/port/win/port_win.cc @@ -215,7 +215,7 @@ int truncate(const char* path, int64_t len) { HANDLE hFile = CreateFile(path, GENERIC_READ | GENERIC_WRITE, - 0, // No sharing while truncating + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, // Security attrs OPEN_EXISTING, // Truncate existing file only FILE_ATTRIBUTE_NORMAL,