From 5f89f80ae5cb60101fd3fde1a0221e0feb870423 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Fri, 24 Jul 2015 19:04:33 -0300 Subject: [PATCH 1/2] Revert "db: dont rethrow exceptions for termination of compaction fiber" Actually we should rethrow exceptions because they are needed for keep_doing() to finish. Otherwise, the future _compaction_done will never be resolved. This reverts commit 89698b0d1c36d2decfe029b49474025eaed1b426. --- database.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database.cc b/database.cc index 15960b2287..d40b527f6b 100644 --- a/database.cc +++ b/database.cc @@ -529,8 +529,10 @@ void column_family::start_compaction() { f.get(); } catch (broken_semaphore& e) { dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); + throw; } catch (seastar::gate_closed_exception& e) { dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); + throw; } catch (std::exception& e) { dblog.error("compaction failed: {}", e.what()); throw; From 15bbb71b7b903822eb82b1ba4691c7808cb698a4 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Fri, 24 Jul 2015 19:08:40 -0300 Subject: [PATCH 2/2] db: handle compaction exception outside keep doing Otherwise, we would needlessly handle it twice. Signed-off-by: Raphael S. Carvalho --- database.cc | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/database.cc b/database.cc index d40b527f6b..dab31fabec 100644 --- a/database.cc +++ b/database.cc @@ -440,8 +440,22 @@ column_family::stop() { return _in_flight_seals.close().then([this] { _compaction_sem.broken(); - return _compaction_done.then([this] { - return make_ready_future<>(); + return _compaction_done.then_wrapped([this] (future<> f) { + // NOTE: broken_semaphore and seastar::gate_closed_exception exceptions + // are used for regular termination of compaction fiber. + try { + f.get(); + } catch (broken_semaphore& e) { + dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); + } catch (seastar::gate_closed_exception& e) { + dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); + } catch (std::exception& e) { + dblog.error("compaction failed: {}", e.what()); + throw; + } catch (...) { + dblog.error("compaction failed: unknown error"); + throw; + } }); }); } @@ -522,24 +536,6 @@ void column_family::start_compaction() { return cs.compact(*this); }); }); - }).then_wrapped([this] (future<> f) { - // NOTE: broken_semaphore and seastar::gate_closed_exception - // exceptions are used to finish keep_doing(). - try { - f.get(); - } catch (broken_semaphore& e) { - dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); - throw; - } catch (seastar::gate_closed_exception& e) { - dblog.info("compaction for column_family {}/{} not restarted due to shutdown", _schema->ks_name(), _schema->cf_name()); - throw; - } catch (std::exception& e) { - dblog.error("compaction failed: {}", e.what()); - throw; - } catch (...) { - dblog.error("compaction failed: unknown error"); - throw; - } }); }); }