From 417bcb122dc49ad676e4821cbb2555dddde110a3 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 30 Mar 2016 19:55:04 +0300 Subject: [PATCH] commitlog: ignore commitlog segments generated by Cassandra-derived tools Cassandra-derived tools (such as sstable2json) may write commitlog segments, that Scylla cannot recognize. Since we now write them with a distinct name, we can recognize the name and ignore these segments, as we know the data they contain is not interesting. Fixes #1112. Message-Id: <1459356904-20699-1-git-send-email-avi@scylladb.com> --- db/commitlog/commitlog.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index cefe4567b3..d4dcd8ba7b 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -882,7 +882,7 @@ db::commitlog::segment_manager::list_descriptors(sstring dirname) { return make_ready_future>(de.type); }; return entry_type(de).then([this, de](std::experimental::optional type) { - if (type == directory_entry_type::regular && de.name[0] != '.') { + if (type == directory_entry_type::regular && de.name[0] != '.' && !is_cassandra_segment(de.name)) { try { _result.emplace_back(de.name); } catch (std::domain_error& e) { @@ -896,6 +896,15 @@ db::commitlog::segment_manager::list_descriptors(sstring dirname) { future<> done() { return _list.done(); } + + static bool is_cassandra_segment(sstring name) { + // We want to ignore commitlog segments generated by Cassandra-derived tools (#1112) + auto c = sstring("Cassandra"); + if (name.size() < c.size()) { + return false; + } + return name.substr(0, c.size()) == c; + } }; return open_checked_directory(commit_error, dirname).then([this, dirname](file dir) {