mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::db: Add interface for pause/continue of background work w/ console cmd.
This commit is contained in:
parent
2eaf5c74c2
commit
70d4b32c3d
3 changed files with 96 additions and 0 deletions
|
@ -48,6 +48,8 @@ namespace ircd::db
|
|||
void setopt(database &, const string_view &key, const string_view &val);
|
||||
void fdeletions(database &, const bool &enable, const bool &force = false);
|
||||
uint64_t checkpoint(database &);
|
||||
void bgcontinue(database &);
|
||||
void bgpause(database &);
|
||||
void resume(database &);
|
||||
void check(database &);
|
||||
void compact(database &, const std::pair<int, int> &level, const compactor & = {});
|
||||
|
|
36
ircd/db.cc
36
ircd/db.cc
|
@ -497,6 +497,42 @@ ircd::db::resume(database &d)
|
|||
};
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::bgpause(database &d)
|
||||
{
|
||||
assert(d.d);
|
||||
const ctx::uninterruptible::nothrow ui;
|
||||
|
||||
throw_on_error
|
||||
{
|
||||
d.d->PauseBackgroundWork()
|
||||
};
|
||||
|
||||
log::debug
|
||||
{
|
||||
log, "'%s': Paused all background work",
|
||||
name(d)
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::bgcontinue(database &d)
|
||||
{
|
||||
assert(d.d);
|
||||
const ctx::uninterruptible::nothrow ui;
|
||||
|
||||
log::debug
|
||||
{
|
||||
log, "'%s': Continuing background work",
|
||||
name(d)
|
||||
};
|
||||
|
||||
throw_on_error
|
||||
{
|
||||
d.d->ContinueBackgroundWork()
|
||||
};
|
||||
}
|
||||
|
||||
/// Writes a snapshot of this database to the directory specified. The
|
||||
/// snapshot consists of hardlinks to the bulk data files of this db, but
|
||||
/// copies the other stuff that usually gets corrupted. The directory can
|
||||
|
|
|
@ -1324,6 +1324,64 @@ console_cmd__db__compressions(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__db__pause(opt &out, const string_view &line)
|
||||
try
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"dbname",
|
||||
}};
|
||||
|
||||
const auto dbname
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
auto &database
|
||||
{
|
||||
db::database::get(dbname)
|
||||
};
|
||||
|
||||
bgpause(database);
|
||||
out << "Paused 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
|
||||
console_cmd__db__continue(opt &out, const string_view &line)
|
||||
try
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"dbname",
|
||||
}};
|
||||
|
||||
const auto dbname
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
auto &database
|
||||
{
|
||||
db::database::get(dbname)
|
||||
};
|
||||
|
||||
bgcontinue(database);
|
||||
out << "Resumed 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
|
||||
console_cmd__db__sync(opt &out, const string_view &line)
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue