From c370cdc123989308f0cf3497aa9fe120c4d9498d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Apr 2019 16:10:01 -0700 Subject: [PATCH] ircd::db: Lock writes after memtable sealed until flush to prevent rocksdb pthread use. --- ircd/db.cc | 59 +++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/ircd/db.cc b/ircd/db.cc index 28f47da1f..b9aabefb0 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -2630,26 +2630,20 @@ noexcept // void -ircd::db::database::events::OnFlushCompleted(rocksdb::DB *const db, - const rocksdb::FlushJobInfo &info) +ircd::db::database::events::OnMemTableSealed(const rocksdb::MemTableInfo &info) noexcept { - log::info + log::debug { - log, "'%s': job:%d ctx:%lu flush ended writes[slow:%d stop:%d] seq[%zu -> %zu] %s '%s' `%s'", + log, "'%s': memory table sealed '%s' entries:%lu deletes:%lu", d->name, - info.job_id, - info.thread_id, - info.triggered_writes_slowdown, - info.triggered_writes_stop, - info.smallest_seqno, - info.largest_seqno, - reflect(info.flush_reason), info.cf_name, - info.file_path, + info.num_entries, + info.num_deletes }; - assert(info.thread_id == ctx::id(*ctx::current)); + const ctx::uninterruptible::nothrow ui; + write_mutex.lock(); } void @@ -2657,6 +2651,8 @@ ircd::db::database::events::OnFlushBegin(rocksdb::DB *const db, const rocksdb::FlushJobInfo &info) noexcept { + assert(info.thread_id == ctx::id(*ctx::current)); + log::info { log, "'%s': job:%d ctx:%lu flush start writes[slow:%d stop:%d] seq[%zu -> %zu] %s '%s'", @@ -2671,7 +2667,30 @@ noexcept info.cf_name, }; + const ctx::uninterruptible::nothrow ui; + write_mutex.unlock(); +} + +void +ircd::db::database::events::OnFlushCompleted(rocksdb::DB *const db, + const rocksdb::FlushJobInfo &info) +noexcept +{ assert(info.thread_id == ctx::id(*ctx::current)); + log::info + { + log, "'%s': job:%d ctx:%lu flush ended writes[slow:%d stop:%d] seq[%zu -> %zu] %s '%s' `%s'", + d->name, + info.job_id, + info.thread_id, + info.triggered_writes_slowdown, + info.triggered_writes_stop, + info.smallest_seqno, + info.largest_seqno, + reflect(info.flush_reason), + info.cf_name, + info.file_path, + }; } void @@ -2818,20 +2837,6 @@ noexcept }; } -void -ircd::db::database::events::OnMemTableSealed(const rocksdb::MemTableInfo &info) -noexcept -{ - log::debug - { - log, "'%s': memory table sealed '%s' entries:%lu deletes:%lu", - d->name, - info.cf_name, - info.num_entries, - info.num_deletes - }; -} - void ircd::db::database::events::OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *const h) noexcept