0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::db: Adjust destruction sequence for rocksdb DB::Close() call.

This commit is contained in:
Jason Volk 2018-04-20 16:22:01 -07:00
parent f3b0fa3b4e
commit 6de7fb7b8c
2 changed files with 31 additions and 18 deletions

View file

@ -97,7 +97,7 @@ struct ircd::db::database
std::vector<string_view> column_names;
std::unordered_map<string_view, size_t> column_index;
std::vector<std::shared_ptr<column>> columns;
custom_ptr<rocksdb::DB> d;
std::unique_ptr<rocksdb::DB> d;
std::unique_ptr<rocksdb::Checkpoint> checkpoint;
unique_const_iterator<decltype(dbs)> dbs_it;

View file

@ -575,22 +575,7 @@ try
throw;
}
return custom_ptr<rocksdb::DB>
{
ptr, [this](rocksdb::DB *const d) noexcept
{
const auto sequence
{
d->GetLatestSequenceNumber()
};
delete d;
log.info("'%s': closed database @ `%s' at sequence number %lu.",
this->name,
this->path,
sequence);
}
};
return std::unique_ptr<rocksdb::DB>(ptr);
}()}
,checkpoint{[this]
{
@ -624,13 +609,14 @@ catch(const std::exception &e)
}
ircd::db::database::~database()
noexcept
noexcept try
{
log.info("'%s': closing database @ `%s'...",
name,
path);
rocksdb::CancelAllBackgroundWork(d.get(), true); // true = blocking
this->checkpoint.reset(nullptr);
this->columns.clear();
log.debug("'%s': flushed columns; background_errors: %lu; synchronizing...",
name,
@ -639,6 +625,33 @@ noexcept
sync(*this);
log.debug("'%s': synchronized with hardware.",
name);
const auto sequence
{
d->GetLatestSequenceNumber()
};
throw_on_error
{
d->Close()
};
log.info("'%s': closed database @ `%s' at sequence number %lu.",
name,
path,
sequence);
}
catch(const std::exception &e)
{
log::error
{
"'%s': Error closing database @ '%s' :%s",
name,
path,
e.what()
};
return;
}
void