From de4b4e593d6f4284310698b67924201aa6b7745d Mon Sep 17 00:00:00 2001 From: Raphael Carvalho Date: Thu, 17 Mar 2016 15:48:58 -0300 Subject: [PATCH] db: better handling of failure in column_family::populate Improve handling of failure by saving first exception and ignoring the remaining futures. At the moment, code only throws first exception and doesn't care about any possible remaining future. Signed-off-by: Raphael Carvalho Message-Id: <383dc4445db09dd2fbce093d4609a0a0bc38a405.1458240398.git.raphaelsc@scylladb.com> --- database.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/database.cc b/database.cc index 049458ae2c..a441842abf 100644 --- a/database.cc +++ b/database.cc @@ -989,13 +989,24 @@ future<> column_family::populate(sstring sstdir) { return make_ready_future<>(); }, &manifest_json_filter).then([&futures] { return when_all(futures.begin(), futures.end()).then([] (std::vector> ret) { - try { - for (auto& f : ret) { - f.get(); + std::exception_ptr eptr; + + for (auto& f : ret) { + try { + if (eptr) { + f.ignore_ready_future(); + } else { + f.get(); + } + } catch(...) { + eptr = std::current_exception(); } - } catch(...) { - throw; } + + if (eptr) { + return make_exception_future<>(eptr); + } + return make_ready_future<>(); }); }).then([verifier, sstdir, descriptor, this] { return parallel_for_each(*verifier, [sstdir = std::move(sstdir), descriptor, this] (auto v) {