From bbef8c3884d273b82d20fcc48477ae8b524bee7b Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Wed, 6 Dec 2017 20:43:52 -0800 Subject: [PATCH] Log GetCurrentTime failures during Flush and Compaction Summary: `GetCurrentTime()` is used to populate `creation_time` table property during flushes and compactions. It is safe to ignore `GetCurrentTime()` failures here but they should be logged. (Note that `creation_time` property was introduced as part of TTL-based FIFO compaction in #2480.) Tes Plan: `make check` Closes https://github.com/facebook/rocksdb/pull/3231 Differential Revision: D6501935 Pulled By: sagar0 fbshipit-source-id: 376adcf4ab801d3a43ec4453894b9a10909c8eb6 --- db/compaction_job.cc | 10 +++++++++- db/flush_job.cc | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/db/compaction_job.cc b/db/compaction_job.cc index c9c71d60c..8886e18c4 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -1325,7 +1325,15 @@ Status CompactionJob::OpenCompactionOutputFile( sub_compact->compaction->MaxInputFileCreationTime(); if (output_file_creation_time == 0) { int64_t _current_time = 0; - db_options_.env->GetCurrentTime(&_current_time); // ignore error + auto status = db_options_.env->GetCurrentTime(&_current_time); + // Safe to proceed even if GetCurrentTime fails. So, log and proceed. + if (!status.ok()) { + ROCKS_LOG_WARN( + db_options_.info_log, + "Failed to get current time to populate creation_time property. " + "Status: %s", + status.ToString().c_str()); + } output_file_creation_time = static_cast(_current_time); } diff --git a/db/flush_job.cc b/db/flush_job.cc index 41a97f587..044248600 100644 --- a/db/flush_job.cc +++ b/db/flush_job.cc @@ -299,7 +299,15 @@ Status FlushJob::WriteLevel0Table() { TEST_SYNC_POINT_CALLBACK("FlushJob::WriteLevel0Table:output_compression", &output_compression_); int64_t _current_time = 0; - db_options_.env->GetCurrentTime(&_current_time); // ignore error + auto status = db_options_.env->GetCurrentTime(&_current_time); + // Safe to proceed even if GetCurrentTime fails. So, log and proceed. + if (!status.ok()) { + ROCKS_LOG_WARN( + db_options_.info_log, + "Failed to get current time to populate creation_time property. " + "Status: %s", + status.ToString().c_str()); + } const uint64_t current_time = static_cast(_current_time); uint64_t oldest_key_time = -- GitLab