From c1a2831d41f0ba61ba80e1101cdec3f51e8f06ac Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 3 Aug 2015 19:18:37 +0300 Subject: [PATCH] db: ignore sstables that clearly don't belong to this shard --- database.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/database.cc b/database.cc index a483dcab7b..795c5e49b6 100644 --- a/database.cc +++ b/database.cc @@ -349,6 +349,16 @@ future<> column_family::probe_file(sstring sstdir, sstring fname) { } void column_family::add_sstable(sstables::sstable&& sstable) { + auto key_shard = [this] (const partition_key& pk) { + auto token = dht::global_partitioner().get_token(*_schema, pk); + return dht::shard_of(token); + }; + auto s1 = key_shard(sstable.get_first_partition_key(*_schema)); + auto s2 = key_shard(sstable.get_last_partition_key(*_schema)); + if (s1 > engine().cpu_id() || engine().cpu_id() < s2) { + dblog.info("sstable {} not relevant for this shard, ignoring", sstable.get_filename()); + return; + } auto generation = sstable.generation(); // allow in-progress reads to continue using old list _sstables = make_lw_shared(*_sstables);