From f2a8bcabc264ac2efedb0d80fa40e28731bf3deb Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Thu, 10 Mar 2016 18:02:17 -0500 Subject: [PATCH] sstables: improve error messages The standard C++ exception messages that will be thrown if there is anything wrong writing the file, are suboptimal: they barely tell us the name of the failing file. Use a specialized create function so that we can capture that better. Signed-off-by: Glauber Costa --- sstables/sstables.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 9904589e75..6aaf432ca7 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -52,6 +52,13 @@ namespace sstables { logging::logger sstlog("sstable"); +future new_sstable_component_file(sstring name, open_flags flags) { + return open_file_dma(name, flags).handle_exception([name] (auto ep) { + sstlog.error("Could not create SSTable component {}. Found exception: {}", name, ep); + return make_exception_future(ep); + }); +} + thread_local std::unordered_map sstable::_shards_agreeing_to_remove_sstable; static utils::phased_barrier& background_jobs() { @@ -749,7 +756,7 @@ void sstable::write_toc(const io_priority_class& pc) { sstlog.debug("Writing TOC file {} ", file_path); // Writing TOC content to temporary file. - file f = open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); + file f = new_sstable_component_file(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); file_output_stream_options options; options.buffer_size = 4096; @@ -792,7 +799,7 @@ void write_crc(const sstring file_path, checksum& c) { sstlog.debug("Writing CRC file {} ", file_path); auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - file f = open_file_dma(file_path, oflags).get0(); + file f = new_sstable_component_file(file_path, oflags).get0(); file_output_stream_options options; options.buffer_size = 4096; @@ -806,7 +813,7 @@ void write_digest(const sstring file_path, uint32_t full_checksum) { sstlog.debug("Writing Digest file {} ", file_path); auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - auto f = open_file_dma(file_path, oflags).get0(); + auto f = new_sstable_component_file(file_path, oflags).get0(); file_output_stream_options options; options.buffer_size = 4096; @@ -876,7 +883,7 @@ template void sstable::write_simple(T& component, const io_priority_class& pc) { auto file_path = filename(Type); sstlog.debug(("Writing " + _component_map[Type] + " file {} ").c_str(), file_path); - file f = open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); + file f = new_sstable_component_file(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); file_output_stream_options options; options.buffer_size = sstable_buffer_size; @@ -945,8 +952,8 @@ future<> sstable::open_data() { future<> sstable::create_data() { auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - return when_all(open_file_dma(filename(component_type::Index), oflags), - open_file_dma(filename(component_type::Data), oflags)).then([this] (auto files) { + return when_all(new_sstable_component_file(filename(component_type::Index), oflags), + new_sstable_component_file(filename(component_type::Data), oflags)).then([this] (auto files) { // FIXME: If both files could not be created, the first get below will // throw an exception, and second get() will not be attempted, and // we'll get a warning about the second future being destructed