From d8586ab22b59fdb14ad2f6202b402b59440149de Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 8 Jul 2015 16:56:31 -0700 Subject: [PATCH] All of these are in the new code added past 3.10 1) Crash in env_win.cc that prevented db_test run to completion and some new tests 2) Fix new corruption tests in DBTest by allowing a shared trunction of files. Note that this is generally needed ONLY for tests. 3) Close database so WAL is closed prior to inducing corruption similar to what we did within Corruption tests. --- db/db_test.cc | 9 +++++++++ port/win/env_win.cc | 2 +- port/win/port_win.cc | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) 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,