mirror of
https://github.com/matrix-construct/construct
synced 2024-09-29 12:18:54 +02:00
ircd::db: Add a background cancel interface w/ console cmd.
This commit is contained in:
parent
55023041b8
commit
fae947d433
3 changed files with 71 additions and 0 deletions
|
@ -48,6 +48,7 @@ namespace ircd::db
|
||||||
void setopt(database &, const string_view &key, const string_view &val);
|
void setopt(database &, const string_view &key, const string_view &val);
|
||||||
void fdeletions(database &, const bool &enable, const bool &force = false);
|
void fdeletions(database &, const bool &enable, const bool &force = false);
|
||||||
uint64_t checkpoint(database &);
|
uint64_t checkpoint(database &);
|
||||||
|
void bgcancel(database &, const bool &blocking = true);
|
||||||
void bgcontinue(database &);
|
void bgcontinue(database &);
|
||||||
void bgpause(database &);
|
void bgpause(database &);
|
||||||
void resume(database &);
|
void resume(database &);
|
||||||
|
|
41
ircd/db.cc
41
ircd/db.cc
|
@ -525,6 +525,47 @@ ircd::db::bgcontinue(database &d)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::db::bgcancel(database &d,
|
||||||
|
const bool &blocking)
|
||||||
|
{
|
||||||
|
assert(d.d);
|
||||||
|
log::debug
|
||||||
|
{
|
||||||
|
log, "'%s': Canceling all background work...",
|
||||||
|
name(d)
|
||||||
|
};
|
||||||
|
|
||||||
|
rocksdb::CancelAllBackgroundWork(d.d.get(), blocking);
|
||||||
|
if(!blocking)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(d.env);
|
||||||
|
assert(d.env->st);
|
||||||
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
for(auto &pool : d.env->st->pool)
|
||||||
|
if(pool)
|
||||||
|
pool->wait();
|
||||||
|
|
||||||
|
const auto errors
|
||||||
|
{
|
||||||
|
property<uint64_t>(d, rocksdb::DB::Properties::kBackgroundErrors)
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto facility
|
||||||
|
{
|
||||||
|
errors? log::facility::ERROR : log::facility::DEBUG
|
||||||
|
};
|
||||||
|
|
||||||
|
log::logf
|
||||||
|
{
|
||||||
|
log, facility,
|
||||||
|
"'%s': Canceled all background work; errors:%lu",
|
||||||
|
name(d),
|
||||||
|
errors
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Writes a snapshot of this database to the directory specified. The
|
/// Writes a snapshot of this database to the directory specified. The
|
||||||
/// snapshot consists of hardlinks to the bulk data files of this db, but
|
/// snapshot consists of hardlinks to the bulk data files of this db, but
|
||||||
/// copies the other stuff that usually gets corrupted. The directory can
|
/// copies the other stuff that usually gets corrupted. The directory can
|
||||||
|
|
|
@ -1441,6 +1441,35 @@ catch(const std::out_of_range &e)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__db__cancel(opt &out, const string_view &line)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"dbname",
|
||||||
|
}};
|
||||||
|
|
||||||
|
const auto dbname
|
||||||
|
{
|
||||||
|
param.at(0)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto &database
|
||||||
|
{
|
||||||
|
db::database::get(dbname)
|
||||||
|
};
|
||||||
|
|
||||||
|
bgcancel(database);
|
||||||
|
out << "canceld background jobs for '" << dbname << "'" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const std::out_of_range &e)
|
||||||
|
{
|
||||||
|
out << "No open database by that name" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__db__sync(opt &out, const string_view &line)
|
console_cmd__db__sync(opt &out, const string_view &line)
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue