Skip to content

Commit

Permalink
Added creation_time to the tables built during repair and recovery.
Browse files Browse the repository at this point in the history
Also handled the return status of GetCurrentTime, so that a garbage
value is not used when return statu is not ok. time is set to 0 instead.
  • Loading branch information
sagar0 committed Jun 25, 2017
1 parent 5d8f184 commit 3a90501
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
13 changes: 12 additions & 1 deletion db/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1263,13 +1263,24 @@ Status CompactionJob::OpenCompactionOutputFile(
bool skip_filters =
cfd->ioptions()->optimize_filters_for_hits && bottommost_level_;

uint64_t output_file_creation_time =
sub_compact->compaction->MaxInputFileCreationTime();
if (output_file_creation_time == 0) {
int64_t _current_time;
auto status = db_options_.env->GetCurrentTime(&_current_time);
if (!status.ok()) {
_current_time = 0;
}
output_file_creation_time = static_cast<uint64_t>(_current_time);
}

sub_compact->builder.reset(NewTableBuilder(
*cfd->ioptions(), cfd->internal_comparator(),
cfd->int_tbl_prop_collector_factories(), cfd->GetID(), cfd->GetName(),
sub_compact->outfile.get(), sub_compact->compaction->output_compression(),
cfd->ioptions()->compression_opts,
sub_compact->compaction->output_level(), &sub_compact->compression_dict,
skip_filters, sub_compact->compaction->MaxInputFileCreationTime()));
skip_filters, output_file_creation_time));
LogFlush(db_options_.info_log);
return s;
}
Expand Down
18 changes: 17 additions & 1 deletion db/db_impl_open.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "db/builder.h"
#include "options/options_helper.h"
#include "rocksdb/wal_filter.h"
#include "table/block_based_table_factory.h"
#include "util/rate_limiter.h"
#include "util/sst_file_manager_impl.h"
#include "util/sync_point.h"
Expand Down Expand Up @@ -164,6 +165,12 @@ static Status ValidateOptions(
"universal and level compaction styles. ");
}
}
if (cfd.options.compaction_options_fifo.ttl > 0 &&
cfd.options.table_factory->Name() != BlockBasedTableFactory().Name()) {
return Status::NotSupported(
"FIFO Compaction with TTL is only supported in "
"Block-Based Table format. ");
}
}

if (db_options.db_paths.size() > 4) {
Expand Down Expand Up @@ -832,6 +839,14 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
*cfd->GetLatestMutableCFOptions();
bool paranoid_file_checks =
cfd->GetLatestMutableCFOptions()->paranoid_file_checks;

int64_t _current_time;
s = env_->GetCurrentTime(&_current_time);
if (!s.ok()) {
_current_time = 0;
}
const uint64_t current_time = static_cast<uint64_t>(_current_time);

{
mutex_.Unlock();

Expand All @@ -851,7 +866,8 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
GetCompressionFlush(*cfd->ioptions(), mutable_cf_options),
cfd->ioptions()->compression_opts, paranoid_file_checks,
cfd->internal_stats(), TableFileCreationReason::kRecovery,
&event_logger_, job_id);
&event_logger_, job_id, Env::IO_HIGH, nullptr /* table_properties */,
-1 /* level */, current_time);
LogFlush(immutable_db_options_.info_log);
ROCKS_LOG_DEBUG(immutable_db_options_.info_log,
"[%s] [WriteLevel0TableForRecovery]"
Expand Down
6 changes: 4 additions & 2 deletions db/flush_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ Status FlushJob::WriteLevel0Table() {
ThreadStatus::STAGE_FLUSH_WRITE_L0);
db_mutex_->AssertHeld();
const uint64_t start_micros = db_options_.env->NowMicros();

Status s;
{
db_mutex_->Unlock();
Expand Down Expand Up @@ -301,7 +300,10 @@ Status FlushJob::WriteLevel0Table() {
db_options_.env->OptimizeForCompactionTableWrite(env_options_, db_options_);

int64_t _current_time;
db_options_.env->GetCurrentTime(&_current_time);
auto status = db_options_.env->GetCurrentTime(&_current_time);
if (!status.ok()) {
_current_time = 0;
}
const uint64_t current_time = static_cast<uint64_t>(_current_time);

s = BuildTable(
Expand Down
12 changes: 11 additions & 1 deletion db/repair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,24 @@ class Repairer {
ScopedArenaIterator iter(mem->NewIterator(ro, &arena));
EnvOptions optimized_env_options =
env_->OptimizeForCompactionTableWrite(env_options_, immutable_db_options_);

int64_t _current_time;
status = env_->GetCurrentTime(&_current_time);
if (!status.ok()) {
_current_time = 0;
}
const uint64_t current_time = static_cast<uint64_t>(_current_time);

status = BuildTable(
dbname_, env_, *cfd->ioptions(), *cfd->GetLatestMutableCFOptions(),
optimized_env_options, table_cache_, iter.get(),
std::unique_ptr<InternalIterator>(mem->NewRangeTombstoneIterator(ro)),
&meta, cfd->internal_comparator(),
cfd->int_tbl_prop_collector_factories(), cfd->GetID(), cfd->GetName(),
{}, kMaxSequenceNumber, kNoCompression, CompressionOptions(), false,
nullptr /* internal_stats */, TableFileCreationReason::kRecovery);
nullptr /* internal_stats */, TableFileCreationReason::kRecovery,
nullptr /* event_logger */, 0 /* job_id */, Env::IO_HIGH,
nullptr /* table_properties */, -1 /* level */, current_time);
ROCKS_LOG_INFO(db_options_.info_log,
"Log #%" PRIu64 ": %d ops saved to Table #%" PRIu64 " %s",
log, counter, meta.fd.GetNumber(),
Expand Down

0 comments on commit 3a90501

Please sign in to comment.