0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-18 07:50:57 +01:00

ircd::db: Disable interruption for rocksdb entry surface.

This commit is contained in:
Jason Volk 2018-08-19 19:30:17 -07:00
parent ff66bc441c
commit d4c51a2d45

View file

@ -191,6 +191,7 @@ ircd::db::init_version()
void void
ircd::db::sync(database &d) ircd::db::sync(database &d)
{ {
const ctx::uninterruptible ui;
throw_on_error throw_on_error
{ {
d.d->SyncWAL() d.d->SyncWAL()
@ -203,6 +204,7 @@ void
ircd::db::flush(database &d, ircd::db::flush(database &d,
const bool &sync) const bool &sync)
{ {
const ctx::uninterruptible ui;
throw_on_error throw_on_error
{ {
d.d->FlushWAL(sync) d.d->FlushWAL(sync)
@ -244,6 +246,7 @@ void
ircd::db::check(database &d) ircd::db::check(database &d)
{ {
assert(d.d); assert(d.d);
const ctx::uninterruptible ui;
throw_on_error throw_on_error
{ {
d.d->VerifyChecksum() d.d->VerifyChecksum()
@ -259,6 +262,7 @@ ircd::db::check(database &d)
uint64_t uint64_t
ircd::db::checkpoint(database &d) ircd::db::checkpoint(database &d)
{ {
const ctx::uninterruptible ui;
if(!d.checkpointer) if(!d.checkpointer)
throw error throw error
{ {
@ -303,6 +307,7 @@ ircd::db::fdeletions(database &d,
const bool &enable, const bool &enable,
const bool &force) const bool &force)
{ {
const ctx::uninterruptible ui;
if(enable) throw_on_error if(enable) throw_on_error
{ {
d.d->EnableFileDeletions(force) d.d->EnableFileDeletions(force)
@ -318,6 +323,7 @@ ircd::db::setopt(database &d,
const string_view &key, const string_view &key,
const string_view &val) const string_view &val)
{ {
const ctx::uninterruptible ui;
const std::unordered_map<std::string, std::string> options const std::unordered_map<std::string, std::string> options
{ {
{ std::string{key}, std::string{val} } { std::string{key}, std::string{val} }
@ -384,6 +390,7 @@ std::vector<std::string>
ircd::db::files(const database &cd, ircd::db::files(const database &cd,
uint64_t &msz) uint64_t &msz)
{ {
const ctx::uninterruptible ui;
std::vector<std::string> ret; std::vector<std::string> ret;
auto &d(const_cast<database &>(cd)); auto &d(const_cast<database &>(cd));
throw_on_error throw_on_error
@ -771,6 +778,8 @@ try
// NOTE: rocksdb sez RepairDB is broken; can't use now // NOTE: rocksdb sez RepairDB is broken; can't use now
if(fsck && fs::is_dir(path)) if(fsck && fs::is_dir(path))
{ {
const ctx::uninterruptible ui;
log::notice log::notice
{ {
log, "Checking database @ `%s' columns[%zu]", path, columns.size() log, "Checking database @ `%s' columns[%zu]", path, columns.size()
@ -793,6 +802,7 @@ try
fs::mkdir(path); fs::mkdir(path);
// Announce attempt before usual point where exceptions are thrown // Announce attempt before usual point where exceptions are thrown
const ctx::uninterruptible ui;
log::info log::info
{ {
log, "Opening database \"%s\" @ `%s' with %zu columns...", log, "Opening database \"%s\" @ `%s' with %zu columns...",
@ -839,6 +849,7 @@ try
}()} }()}
,uuid{[this] ,uuid{[this]
{ {
const ctx::uninterruptible ui;
std::string ret; std::string ret;
throw_on_error throw_on_error
{ {
@ -849,6 +860,7 @@ try
}()} }()}
,checkpointer{[this] ,checkpointer{[this]
{ {
const ctx::uninterruptible ui;
rocksdb::Checkpoint *checkpointer{nullptr}; rocksdb::Checkpoint *checkpointer{nullptr};
throw_on_error throw_on_error
{ {
@ -866,6 +878,7 @@ try
this->name this->name
}; };
const ctx::uninterruptible ui;
check(*this); check(*this);
} }
@ -900,6 +913,8 @@ catch(const std::exception &e)
ircd::db::database::~database() ircd::db::database::~database()
noexcept try noexcept try
{ {
const ctx::uninterruptible::nothrow ui;
log::info log::info
{ {
log, "'%s': closing database @ `%s'...", log, "'%s': closing database @ `%s'...",
@ -1184,6 +1199,7 @@ const noexcept
void void
ircd::db::drop(database::column &c) ircd::db::drop(database::column &c)
{ {
const ctx::uninterruptible ui;
if(!c.handle) if(!c.handle)
return; return;
@ -3577,14 +3593,19 @@ ircd::db::for_each(database &d,
const seq_closure_bool &closure) const seq_closure_bool &closure)
{ {
std::unique_ptr<rocksdb::TransactionLogIterator> tit; std::unique_ptr<rocksdb::TransactionLogIterator> tit;
throw_on_error
{ {
d.d->GetUpdatesSince(seq, &tit) const ctx::uninterruptible ui;
}; throw_on_error
{
d.d->GetUpdatesSince(seq, &tit)
};
}
assert(bool(tit)); assert(bool(tit));
for(; tit->Valid(); tit->Next()) for(; tit->Valid(); tit->Next())
{ {
const ctx::uninterruptible ui;
auto batchres auto batchres
{ {
tit->GetBatch() tit->GetBatch()
@ -3998,6 +4019,7 @@ ircd::db::txn::checkpoint::checkpoint(txn &t)
ircd::db::txn::checkpoint::~checkpoint() ircd::db::txn::checkpoint::~checkpoint()
noexcept noexcept
{ {
const ctx::uninterruptible ui;
if(likely(!std::uncaught_exception())) if(likely(!std::uncaught_exception()))
throw_on_error { t.wb->PopSavePoint() }; throw_on_error { t.wb->PopSavePoint() };
else else
@ -4742,10 +4764,13 @@ ircd::db::row::row(database &d,
//TODO: does this block? //TODO: does this block?
std::vector<Iterator *> iterators; std::vector<Iterator *> iterators;
throw_on_error
{ {
d.d->NewIterators(options, handles, &iterators) const ctx::uninterruptible ui;
}; throw_on_error
{
d.d->NewIterators(options, handles, &iterators)
};
}
for(size_t i(0); i < this->size() && i < column_count; ++i) for(size_t i(0); i < this->size() && i < column_count; ++i)
{ {
@ -5038,11 +5063,13 @@ void
ircd::db::sort(column &column, ircd::db::sort(column &column,
const bool &blocking) const bool &blocking)
{ {
const ctx::uninterruptible ui;
database::column &c(column); database::column &c(column);
database &d(*c.d); database &d(*c.d);
rocksdb::FlushOptions opts; rocksdb::FlushOptions opts;
opts.wait = blocking; opts.wait = blocking;
log::debug log::debug
{ {
log, "'%s':'%s' @%lu FLUSH (sort)", log, "'%s':'%s' @%lu FLUSH (sort)",
@ -5151,6 +5178,7 @@ ircd::db::setopt(column &column,
const string_view &key, const string_view &key,
const string_view &val) const string_view &val)
{ {
const ctx::uninterruptible ui;
const std::unordered_map<std::string, std::string> options const std::unordered_map<std::string, std::string> options
{ {
{ std::string{key}, std::string{val} } { std::string{key}, std::string{val} }
@ -5169,13 +5197,17 @@ ircd::db::del(column &column,
const string_view &key, const string_view &key,
const sopts &sopts) const sopts &sopts)
{ {
database &d(column); const ctx::uninterruptible ui;
database::column &c(column); database::column &c(column);
log.debug("'%s' %lu '%s' DELETE key(%zu B)", database &d(column);
name(d), log::debug
sequence(d), {
name(c), log, "'%s' %lu '%s' DELETE key(%zu B)",
key.size()); name(d),
sequence(d),
name(c),
key.size()
};
auto opts(make_opts(sopts)); auto opts(make_opts(sopts));
throw_on_error throw_on_error
@ -5190,14 +5222,18 @@ ircd::db::write(column &column,
const const_buffer &val, const const_buffer &val,
const sopts &sopts) const sopts &sopts)
{ {
database &d(column); const ctx::uninterruptible ui;
database::column &c(column); database::column &c(column);
log.debug("'%s' %lu '%s' PUT key(%zu B) val(%zu B)", database &d(column);
name(d), log::debug
sequence(d), {
name(c), log, "'%s' %lu '%s' PUT key(%zu B) val(%zu B)",
size(key), name(d),
size(val)); sequence(d),
name(c),
size(key),
size(val)
};
auto opts(make_opts(sopts)); auto opts(make_opts(sopts));
throw_on_error throw_on_error
@ -5724,6 +5760,8 @@ ircd::db::commit(database &d,
rocksdb::WriteBatch &batch, rocksdb::WriteBatch &batch,
const rocksdb::WriteOptions &opts) const rocksdb::WriteOptions &opts)
{ {
const ctx::uninterruptible ui;
#ifdef RB_DEBUG #ifdef RB_DEBUG
ircd::timer timer; ircd::timer timer;
#endif #endif
@ -5834,6 +5872,8 @@ ircd::db::seek(database::column &c,
const rocksdb::ReadOptions &opts, const rocksdb::ReadOptions &opts,
std::unique_ptr<rocksdb::Iterator> &it) std::unique_ptr<rocksdb::Iterator> &it)
{ {
const ctx::uninterruptible ui;
if(!it) if(!it)
{ {
database &d(*c.d); database &d(*c.d);
@ -6092,6 +6132,7 @@ ircd::db::insert(rocksdb::Cache &cache,
delete s; delete s;
}}; }};
const ctx::uninterruptible ui;
auto s auto s
{ {
std::make_unique<rocksdb::Slice>(data(value), size(value)) std::make_unique<rocksdb::Slice>(data(value), size(value))
@ -6237,6 +6278,7 @@ ircd::db::column_names(const std::string &path,
const rocksdb::DBOptions &opts) const rocksdb::DBOptions &opts)
try try
{ {
const ctx::uninterruptible ui;
std::vector<std::string> ret; std::vector<std::string> ret;
throw_on_error throw_on_error
{ {