0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd::db: Update event-listener related.

This commit is contained in:
Jason Volk 2018-09-18 18:04:41 -07:00
parent 5698637dd6
commit b979426f7a
2 changed files with 175 additions and 43 deletions

View file

@ -21,6 +21,7 @@ struct ircd::db::database::events final
{ {
database *d; database *d;
void OnFlushBegin(rocksdb::DB *, const rocksdb::FlushJobInfo &) noexcept override;
void OnFlushCompleted(rocksdb::DB *, const rocksdb::FlushJobInfo &) noexcept override; void OnFlushCompleted(rocksdb::DB *, const rocksdb::FlushJobInfo &) noexcept override;
void OnCompactionCompleted(rocksdb::DB *, const rocksdb::CompactionJobInfo &) noexcept override; void OnCompactionCompleted(rocksdb::DB *, const rocksdb::CompactionJobInfo &) noexcept override;
void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &) noexcept override; void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &) noexcept override;
@ -28,6 +29,9 @@ struct ircd::db::database::events final
void OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &) noexcept override; void OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &) noexcept override;
void OnMemTableSealed(const rocksdb::MemTableInfo &) noexcept override; void OnMemTableSealed(const rocksdb::MemTableInfo &) noexcept override;
void OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *) noexcept override; void OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *) noexcept override;
void OnExternalFileIngested(rocksdb::DB *, const rocksdb::ExternalFileIngestionInfo &) noexcept override;
void OnBackgroundError(rocksdb::BackgroundErrorReason, rocksdb::Status *) noexcept override;
void OnStallConditionsChanged(const rocksdb::WriteStallInfo &) noexcept override;
events(database *const &d) events(database *const &d)
:d{d} :d{d}

View file

@ -1940,15 +1940,41 @@ ircd::db::database::events::OnFlushCompleted(rocksdb::DB *const db,
const rocksdb::FlushJobInfo &info) const rocksdb::FlushJobInfo &info)
noexcept noexcept
{ {
rog.debug("'%s' @%p: flushed: column[%s] path[%s] tid[%lu] job[%d] writes[slow:%d stop:%d]", log::info
d->name, {
db, rog, "'%s' flush complete: column[%s] path[%s] ctx[%lu] job[%d] writes[slow:%d stop:%d] seq[%zu -> %zu] reason:%d",
info.cf_name, d->name,
info.file_path, info.cf_name,
info.thread_id, info.file_path,
info.job_id, info.thread_id,
info.triggered_writes_slowdown, info.job_id,
info.triggered_writes_stop); info.triggered_writes_slowdown,
info.triggered_writes_stop,
info.smallest_seqno,
info.largest_seqno,
int(info.flush_reason)
};
}
void
ircd::db::database::events::OnFlushBegin(rocksdb::DB *const db,
const rocksdb::FlushJobInfo &info)
noexcept
{
log::info
{
rog, "'%s' flush begin column[%s] path[%s] ctx[%lu] job[%d] writes[slow:%d stop:%d] seq[%zu -> %zu] reason:%d",
d->name,
info.cf_name,
info.file_path,
info.thread_id,
info.job_id,
info.triggered_writes_slowdown,
info.triggered_writes_stop,
info.smallest_seqno,
info.largest_seqno,
int(info.flush_reason)
};
} }
void void
@ -1956,70 +1982,172 @@ ircd::db::database::events::OnCompactionCompleted(rocksdb::DB *const db,
const rocksdb::CompactionJobInfo &info) const rocksdb::CompactionJobInfo &info)
noexcept noexcept
{ {
rog.debug("'%s' @%p: compacted: column[%s] status[%d] tid[%lu] job[%d]", log::info
d->name, {
db, rog, "'%s' compacted column[%s] ctx[%lu] job[%d] level[in:%d out:%d] files[in:%zu out:%zu] reason:%d :%s",
info.cf_name, d->name,
int(info.status.code()), info.cf_name,
info.thread_id, info.thread_id,
info.job_id); info.job_id,
info.base_input_level,
info.output_level,
info.input_files.size(),
info.output_files.size(),
int(info.compaction_reason),
info.status.ToString()
};
} }
void void
ircd::db::database::events::OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &info) ircd::db::database::events::OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &info)
noexcept noexcept
{ {
rog.debug("'%s': table file deleted: db[%s] path[%s] status[%d] job[%d]", log::debug
d->name, {
info.db_name, rog, "'%s': table file deleted: db[%s] path[%s] status[%d] job[%d]",
info.file_path, d->name,
int(info.status.code()), info.db_name,
info.job_id); info.file_path,
int(info.status.code()),
info.job_id
};
} }
void void
ircd::db::database::events::OnTableFileCreated(const rocksdb::TableFileCreationInfo &info) ircd::db::database::events::OnTableFileCreated(const rocksdb::TableFileCreationInfo &info)
noexcept noexcept
{ {
rog.debug("'%s': table file created: db[%s] path[%s] status[%d] job[%d]", log::debug
d->name, {
info.db_name, rog, "'%s': table file created: db[%s] path[%s] status[%d] job[%d]",
info.file_path, d->name,
int(info.status.code()), info.db_name,
info.job_id); info.file_path,
int(info.status.code()),
info.job_id
};
} }
void void
ircd::db::database::events::OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &info) ircd::db::database::events::OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &info)
noexcept noexcept
{ {
rog.debug("'%s': table file creating: db[%s] column[%s] path[%s] job[%d]", log::debug
d->name, {
info.db_name, rog, "'%s': table file creating: db[%s] column[%s] path[%s] job[%d]",
info.cf_name, d->name,
info.file_path, info.db_name,
info.job_id); info.cf_name,
info.file_path,
info.job_id
};
} }
void void
ircd::db::database::events::OnMemTableSealed(const rocksdb::MemTableInfo &info) ircd::db::database::events::OnMemTableSealed(const rocksdb::MemTableInfo &info)
noexcept noexcept
{ {
rog.debug("'%s': memory table sealed: column[%s] entries[%lu] deletes[%lu]", log::debug
d->name, {
info.cf_name, rog, "'%s': memory table sealed: column[%s] entries[%lu] deletes[%lu]",
info.num_entries, d->name,
info.num_deletes); info.cf_name,
info.num_entries,
info.num_deletes
};
} }
void void
ircd::db::database::events::OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *const h) ircd::db::database::events::OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *const h)
noexcept noexcept
{ {
rog.debug("'%s': column[%s] handle closing @ %p", log::debug
d->name, {
h->GetName(), rog, "'%s': column[%s] handle closing @ %p",
h); d->name,
h->GetName(),
h
};
}
void
ircd::db::database::events::OnExternalFileIngested(rocksdb::DB *const d,
const rocksdb::ExternalFileIngestionInfo &info)
noexcept
{
log::notice
{
rog, "'%s' external file ingested column[%s] external[%s] internal[%s] sequence:%lu",
this->d->name,
info.cf_name,
info.external_file_path,
info.internal_file_path,
info.global_seqno
};
}
void
ircd::db::database::events::OnBackgroundError(rocksdb::BackgroundErrorReason reason,
rocksdb::Status *const status)
noexcept
{
string_view str{"?????"}; switch(reason)
{
case rocksdb::BackgroundErrorReason::kFlush:
str = "FLUSH";
break;
case rocksdb::BackgroundErrorReason::kCompaction:
str = "COMPACTION";
break;
case rocksdb::BackgroundErrorReason::kWriteCallback:
str = "WRITE";
break;
case rocksdb::BackgroundErrorReason::kMemTable:
str = "MEMTABLE";
break;
}
assert(status);
log::error
{
rog, "'%s' background error in %s :%s",
d->name,
str,
status->ToString()
};
}
void
ircd::db::database::events::OnStallConditionsChanged(const rocksdb::WriteStallInfo &info)
noexcept
{
static const auto str{[]
(const rocksdb::WriteStallCondition &c)
-> string_view
{
return
c == rocksdb::WriteStallCondition::kNormal?
"NORMAL"_sv:
c == rocksdb::WriteStallCondition::kDelayed?
"DELAYED"_sv:
c == rocksdb::WriteStallCondition::kStopped?
"STOPPED"_sv:
"UNKNOWN"_sv;
}};
log::warning
{
rog, "'%s' stall condition column[%s] %d (%s) -> %d (%s)",
d->name,
info.cf_name,
info.condition.prev,
str(info.condition.prev),
info.condition.cur,
str(info.condition.cur),
};
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////