Skip to content

Commit

Permalink
Add more tests to ASSERT_STATUS_CHECKED (3), API change (#7715)
Browse files Browse the repository at this point in the history
Summary:
Third batch of adding more tests to ASSERT_STATUS_CHECKED.

* db_compaction_filter_test
* db_compaction_test
* db_dynamic_level_test
* db_inplace_update_test
* db_sst_test
* db_tailing_iter_test
* db_io_failure_test

Also update GetApproximateSizes APIs to all return Status.

Pull Request resolved: facebook/rocksdb#7715

Reviewed By: jay-zhuang

Differential Revision: D25806896

Pulled By: pdillinger

fbshipit-source-id: 6cb9d62ba5a756c645812754c596ad3995d7c262
Signed-off-by: Changlong Chen <levisonchen@live.cn>
  • Loading branch information
adamretter authored and mm304321141 committed Jun 23, 2021
1 parent cd5fabd commit 0cddd7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions file/delete_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ Status DeleteScheduler::DeleteFile(const std::string& file_path,

// Update the total trash size
uint64_t trash_file_size = 0;
Status ignored =
IOStatus io_s =
fs_->GetFileSize(trash_file, IOOptions(), &trash_file_size, nullptr);
ignored.PermitUncheckedError(); //**TODO: What should we do if we failed to
// get the file size?
total_trash_size_.fetch_add(trash_file_size);
if (io_s.ok()) {
total_trash_size_.fetch_add(trash_file_size);
}
//**TODO: What should we do if we failed to
// get the file size?

// Add file to delete queue
{
Expand Down Expand Up @@ -199,9 +201,7 @@ Status DeleteScheduler::MarkAsTrash(const std::string& file_path,
cnt++;
}
if (s.ok()) {
//**TODO: What should we do if this returns an error?
sst_file_manager_->OnMoveFile(file_path, *trash_file)
.PermitUncheckedError();
s = sst_file_manager_->OnMoveFile(file_path, *trash_file);
}
return s;
}
Expand Down
4 changes: 2 additions & 2 deletions file/sst_file_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool SstFileManagerImpl::IsMaxAllowedSpaceReachedIncludingCompactions() {

bool SstFileManagerImpl::EnoughRoomForCompaction(
ColumnFamilyData* cfd, const std::vector<CompactionInputFiles>& inputs,
Status bg_error) {
const Status& bg_error) {
MutexLock l(&mu_);
uint64_t size_added_by_compaction = 0;
// First check if we even have the space to do the compaction
Expand All @@ -183,7 +183,7 @@ bool SstFileManagerImpl::EnoughRoomForCompaction(
// seen a NoSpace() error. This is tin order to contain a single potentially
// misbehaving DB instance and prevent it from slowing down compactions of
// other DB instances
if (bg_error == Status::NoSpace() && CheckFreeSpace()) {
if (bg_error.IsNoSpace() && CheckFreeSpace()) {
auto fn =
TableFileName(cfd->ioptions()->cf_paths, inputs[0][0]->fd.GetNumber(),
inputs[0][0]->fd.GetPathId());
Expand Down
4 changes: 2 additions & 2 deletions file/sst_file_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ROCKSDB_NAMESPACE {
class Env;
class Logger;

// SstFileManager is used to track SST files in the DB and control there
// SstFileManager is used to track SST files in the DB and control their
// deletion rate.
// All SstFileManager public functions are thread-safe.
class SstFileManagerImpl : public SstFileManager {
Expand Down Expand Up @@ -77,7 +77,7 @@ class SstFileManagerImpl : public SstFileManager {
// the full compaction size).
bool EnoughRoomForCompaction(ColumnFamilyData* cfd,
const std::vector<CompactionInputFiles>& inputs,
Status bg_error);
const Status& bg_error);

// Bookkeeping so total_file_sizes_ goes back to normal after compaction
// finishes
Expand Down

0 comments on commit 0cddd7f

Please sign in to comment.