Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug in nano::rocksdb::store::clear() #4279

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions nano/node/rocksdb/rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,19 +722,19 @@ int nano::rocksdb::store::drop (nano::write_transaction const & transaction_a, t

int nano::rocksdb::store::clear (::rocksdb::ColumnFamilyHandle * column_family)
{
// Dropping completely removes the column
auto name = column_family->GetName ();
auto status = db->DropColumnFamily (column_family);
release_assert (status.ok ());
::rocksdb::ReadOptions read_options;
::rocksdb::WriteOptions write_options;
::rocksdb::WriteBatch write_batch;
std::unique_ptr<::rocksdb::Iterator> it (db->NewIterator (read_options, column_family));

// Need to add it back as we just want to clear the contents
auto handle_it = std::find_if (handles.begin (), handles.end (), [column_family] (auto & handle) {
return handle.get () == column_family;
});
debug_assert (handle_it != handles.cend ());
status = db->CreateColumnFamily (get_cf_options (name), name, &column_family);
for (it->SeekToFirst (); it->Valid (); it->Next ())
{
write_batch.Delete (column_family, it->key ());
}

::rocksdb::Status status = db->Write (write_options, &write_batch);
release_assert (status.ok ());
handle_it->reset (column_family);

return status.code ();
}

Expand Down
Loading