From 149aea32e7c881099bc200138fdb4b4438f448ae Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Mon, 4 Jan 2016 14:48:54 +0200 Subject: [PATCH] database: filter out a manifest.json files Filter out manifest.json files when reading sstables during bootup and when loading new sstables ('nodetool refresh'). Fixes issue #529 Signed-off-by: Vlad Zolotarov Message-Id: <1451911734-26511-3-git-send-email-vladz@cloudius-systems.com> --- database.cc | 15 +++++++++++++-- database.hh | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/database.cc b/database.cc index 4c9b14bd6d..8b8ab655b8 100644 --- a/database.cc +++ b/database.cc @@ -687,7 +687,7 @@ column_family::reshuffle_sstables(int64_t start) { // Those SSTables are not known by anyone in the system. So we don't have any kind of // object describing them. There isn't too much of a choice. return work.sstables[comps.generation]->read_toc(); - }).then([&work] { + }, &manifest_json_filter).then([&work] { // Note: cannot be parallel because we will be shuffling things around at this stage. Can't race. return do_for_each(work.sstables, [&work] (auto& pair) { auto&& comps = std::move(work.descriptors.at(pair.first)); @@ -853,6 +853,17 @@ lw_shared_ptr column_family::get_sstables() { return _sstables; } +inline bool column_family::manifest_json_filter(const sstring& fname) { + using namespace boost::filesystem; + + path entry_path(fname); + if (!is_directory(status(entry_path)) && entry_path.filename() == path("manifest.json")) { + return false; + } + + return true; +} + future<> column_family::populate(sstring sstdir) { // We can catch most errors when we try to load an sstable. But if the TOC // file is the one missing, we won't try to load the sstable at all. This @@ -914,7 +925,7 @@ future<> column_family::populate(sstring sstdir) { futures.push_back(std::move(f)); return make_ready_future<>(); - }).then([&futures] { + }, &manifest_json_filter).then([&futures] { return when_all(futures.begin(), futures.end()).then([] (std::vector> ret) { try { for (auto& f : ret) { diff --git a/database.hh b/database.hh index fb6889f5d1..5c7470ab9f 100644 --- a/database.hh +++ b/database.hh @@ -351,6 +351,9 @@ private: // one are also complete future<> seal_active_memtable(); + // filter manifest.json files out + static bool manifest_json_filter(const sstring& fname); + seastar::gate _in_flight_seals; // Iterate over all partitions. Protocol is the same as std::all_of(),