mirror of
https://github.com/matrix-construct/construct
synced 2024-09-30 12:48:54 +02:00
ircd::db: Add WAL fflush; move table flushes to "sort()"; adjust interfaces.
This commit is contained in:
parent
93ca1448d1
commit
8083a5d71c
4 changed files with 75 additions and 22 deletions
|
@ -48,7 +48,7 @@ namespace ircd::db
|
||||||
// [SET] Other operations
|
// [SET] Other operations
|
||||||
void setopt(column &, const string_view &key, const string_view &val);
|
void setopt(column &, const string_view &key, const string_view &val);
|
||||||
void compact(column &, const string_view &begin = {}, const string_view &end = {});
|
void compact(column &, const string_view &begin = {}, const string_view &end = {});
|
||||||
void flush(column &, const bool &blocking = false);
|
void sort(column &, const bool &blocking = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Columns add the ability to run multiple LevelDB's in synchrony under the same
|
/// Columns add the ability to run multiple LevelDB's in synchrony under the same
|
||||||
|
|
|
@ -44,10 +44,11 @@ namespace ircd::db
|
||||||
|
|
||||||
// Control panel
|
// Control panel
|
||||||
void setopt(database &, const string_view &key, const string_view &val);
|
void setopt(database &, const string_view &key, const string_view &val);
|
||||||
void compact(database &);
|
|
||||||
void fdeletions(database &, const bool &enable, const bool &force = false);
|
void fdeletions(database &, const bool &enable, const bool &force = false);
|
||||||
void checkpoint(database &, const string_view &dir);
|
void checkpoint(database &, const string_view &dir);
|
||||||
void flush(database &, const bool &blocking = true);
|
void compact(database &);
|
||||||
|
void sort(database &, const bool &blocking = true);
|
||||||
|
void flush(database &, const bool &sync = false);
|
||||||
void sync(database &);
|
void sync(database &);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
ircd/db.cc
54
ircd/db.cc
|
@ -135,12 +135,36 @@ ircd::db::sync(database &d)
|
||||||
/// each column individually.
|
/// each column individually.
|
||||||
void
|
void
|
||||||
ircd::db::flush(database &d,
|
ircd::db::flush(database &d,
|
||||||
const bool &blocking)
|
const bool &sync)
|
||||||
|
{
|
||||||
|
throw_on_error
|
||||||
|
{
|
||||||
|
d.d->FlushWAL(sync)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Moves memory structures to SST files for all columns. This doesn't
|
||||||
|
/// necessarily sort anything that wasn't previously sorted, but it may create
|
||||||
|
/// new SST files and shouldn't be confused with a typical fflush().
|
||||||
|
/// Note that if blocking=true, blocking may occur for each column individually.
|
||||||
|
void
|
||||||
|
ircd::db::sort(database &d,
|
||||||
|
const bool &blocking)
|
||||||
{
|
{
|
||||||
for(const auto &c : d.columns)
|
for(const auto &c : d.columns)
|
||||||
{
|
{
|
||||||
db::column column{*c};
|
db::column column{*c};
|
||||||
db::flush(column, blocking);
|
db::sort(column, blocking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::db::compact(database &d)
|
||||||
|
{
|
||||||
|
for(const auto &c : d.columns)
|
||||||
|
{
|
||||||
|
db::column column{*c};
|
||||||
|
compact(column, string_view{}, string_view{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,16 +214,6 @@ ircd::db::fdeletions(database &d,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ircd::db::compact(database &d)
|
|
||||||
{
|
|
||||||
for(const auto &c : d.columns)
|
|
||||||
{
|
|
||||||
db::column column{*c};
|
|
||||||
compact(column, string_view{}, string_view{});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::db::setopt(database &d,
|
ircd::db::setopt(database &d,
|
||||||
const string_view &key,
|
const string_view &key,
|
||||||
|
@ -628,12 +642,16 @@ noexcept try
|
||||||
path);
|
path);
|
||||||
|
|
||||||
rocksdb::CancelAllBackgroundWork(d.get(), true); // true = blocking
|
rocksdb::CancelAllBackgroundWork(d.get(), true); // true = blocking
|
||||||
this->checkpoint.reset(nullptr);
|
log.debug("'%s': background_errors: %lu; flushing...",
|
||||||
this->columns.clear();
|
|
||||||
log.debug("'%s': closed columns; background_errors: %lu; synchronizing...",
|
|
||||||
name,
|
name,
|
||||||
property<uint64_t>(*this, rocksdb::DB::Properties::kBackgroundErrors));
|
property<uint64_t>(*this, rocksdb::DB::Properties::kBackgroundErrors));
|
||||||
|
|
||||||
|
flush(*this);
|
||||||
|
this->checkpoint.reset(nullptr);
|
||||||
|
this->columns.clear();
|
||||||
|
log.debug("'%s': closed columns; synchronizing...",
|
||||||
|
name);
|
||||||
|
|
||||||
sync(*this);
|
sync(*this);
|
||||||
log.debug("'%s': synchronized with hardware.",
|
log.debug("'%s': synchronized with hardware.",
|
||||||
name);
|
name);
|
||||||
|
@ -3944,14 +3962,14 @@ ircd::db::describe(const column &column)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::db::flush(column &column,
|
ircd::db::sort(column &column,
|
||||||
const bool &blocking)
|
const bool &blocking)
|
||||||
{
|
{
|
||||||
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("'%s':'%s' @%lu FLUSH",
|
log.debug("'%s':'%s' @%lu FLUSH (sort)",
|
||||||
name(d),
|
name(d),
|
||||||
name(c),
|
name(c),
|
||||||
sequence(d));
|
sequence(d));
|
||||||
|
|
|
@ -818,6 +818,40 @@ catch(const std::out_of_range &e)
|
||||||
bool
|
bool
|
||||||
console_cmd__db__flush(opt &out, const string_view &line)
|
console_cmd__db__flush(opt &out, const string_view &line)
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"dbname", "[sync]"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const auto dbname
|
||||||
|
{
|
||||||
|
param.at(0)
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto sync
|
||||||
|
{
|
||||||
|
param.at(1, false)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto &database
|
||||||
|
{
|
||||||
|
*db::database::dbs.at(dbname)
|
||||||
|
};
|
||||||
|
|
||||||
|
flush(database, sync);
|
||||||
|
out << "done" << 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__sort(opt &out, const string_view &line)
|
||||||
|
try
|
||||||
{
|
{
|
||||||
const params param{line, " ",
|
const params param{line, " ",
|
||||||
{
|
{
|
||||||
|
@ -839,7 +873,7 @@ try
|
||||||
*db::database::dbs.at(dbname)
|
*db::database::dbs.at(dbname)
|
||||||
};
|
};
|
||||||
|
|
||||||
flush(database, blocking);
|
sort(database, blocking);
|
||||||
out << "done" << std::endl;
|
out << "done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue