Skip to content

Commit

Permalink
create_snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Oct 19, 2023
1 parent 67d0f86 commit 39fdf93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/limestone/api/datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class datastore {
* @param from the location of log files
* @attention this function is not thread-safe.
*/
void create_snapshot() noexcept;
void create_snapshot();

epoch_id_type last_durable_epoch_in_dir() noexcept;

Expand Down
12 changes: 6 additions & 6 deletions src/limestone/datastore_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int comp_twisted_key(const std::string_view& a, const std::string_view& b
return std::memcmp(b.data(), a.data(), write_version_size);
}

void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cognitive-complexity)
void datastore::create_snapshot() { // NOLINT(readability-function-cognitive-complexity)
auto& from_dir = location_;
#if defined SORT_METHOD_PUT_ONLY
auto sortdb = std::make_unique<sortdb_wrapper>(from_dir, comp_twisted_key);
Expand Down Expand Up @@ -208,7 +208,7 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog
const bool result_mkdir = boost::filesystem::create_directory(sub_dir, error);
if (!result_mkdir || error) {
LOG_LP(ERROR) << "fail to create directory";
std::abort();
throw std::runtime_error("I/O error");
}
}

Expand All @@ -217,7 +217,7 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog
FILE* ostrm = fopen(snapshot_file.c_str(), "w"); // NOLINT(*-owning-memory)
if (!ostrm) {
LOG_LP(ERROR) << "cannot create snapshot file (" << snapshot_file << ")";
std::abort();
throw std::runtime_error("I/O error");
}
setvbuf(ostrm, nullptr, _IOFBF, 128L * 1024L); // NOLINT, NB. glibc may ignore size when _IOFBF and buffer=NULL
static_assert(sizeof(log_entry::entry_type) == 1);
Expand Down Expand Up @@ -245,7 +245,7 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog
break; // skip
default:
LOG(ERROR) << "never reach " << static_cast<int>(entry_type);
std::abort();
throw std::runtime_error("I/O error");
}
});
#else
Expand All @@ -260,13 +260,13 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog
break; // skip
default:
LOG(ERROR) << "never reach " << static_cast<int>(entry_type);
std::abort();
throw std::runtime_error("I/O error");
}
});
#endif
if (fclose(ostrm) != 0) { // NOLINT(*-owning-memory)
LOG_LP(ERROR) << "cannot close snapshot file (" << snapshot_file << "), errno = " << errno;
std::abort();
throw std::runtime_error("I/O error");
}
}

Expand Down

0 comments on commit 39fdf93

Please sign in to comment.