mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-25 22:44:05 +00:00
Invoke OnTableFileCreated for empty SSTs (#4307)
Summary:
The API comment on `OnTableFileCreationStarted` (b6280d01f9/include/rocksdb/listener.h (L331-L333)
) led users to believe a call to `OnTableFileCreationStarted` will always be matched with a call to `OnTableFileCreated`. However, we were skipping the `OnTableFileCreated` call in one case: no error happens but also no file is generated since there's no data.
This PR adds the call to `OnTableFileCreated` for that case. The filename will be "(nil)" and the size will be zero.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4307
Differential Revision: D9485201
Pulled By: ajkr
fbshipit-source-id: 2f077ec7913f128487aae2624c69a50762394df6
This commit is contained in:
parent
cf7150ac2e
commit
ee234e83e3
|
@ -1,6 +1,8 @@
|
|||
# Rocksdb Change Log
|
||||
## Unreleased
|
||||
### Public API Change
|
||||
* `OnTableFileCreated` will now be called for empty files generated during compaction. In that case, `TableFileCreationInfo::file_path` will be "(nil)" and `TableFileCreationInfo::file_size` will be zero.
|
||||
|
||||
### New Features
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -1308,9 +1308,7 @@ Status CompactionJob::FinishCompactionOutputFile(
|
|||
// VersionEdit.
|
||||
assert(!sub_compact->outputs.empty());
|
||||
sub_compact->outputs.pop_back();
|
||||
sub_compact->builder.reset();
|
||||
sub_compact->current_output_file_size = 0;
|
||||
return s;
|
||||
meta = nullptr;
|
||||
}
|
||||
|
||||
if (s.ok() && (current_entries > 0 || tp.num_range_deletions > 0)) {
|
||||
|
|
|
@ -1221,7 +1221,9 @@ class DbStressListener : public EventListener {
|
|||
const std::vector<ColumnFamilyDescriptor>& column_families)
|
||||
: db_name_(db_name), db_paths_(db_paths),
|
||||
column_families_(column_families) {}
|
||||
virtual ~DbStressListener() {}
|
||||
virtual ~DbStressListener() {
|
||||
assert(num_pending_file_creations_ == 0);
|
||||
}
|
||||
#ifndef ROCKSDB_LITE
|
||||
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
|
||||
assert(IsValidColumnFamilyName(info.cf_name));
|
||||
|
@ -1246,16 +1248,23 @@ class DbStressListener : public EventListener {
|
|||
std::chrono::microseconds(Random::GetTLSInstance()->Uniform(5000)));
|
||||
}
|
||||
|
||||
virtual void OnTableFileCreationStarted(
|
||||
const TableFileCreationBriefInfo& /*info*/) {
|
||||
++num_pending_file_creations_;
|
||||
}
|
||||
virtual void OnTableFileCreated(const TableFileCreationInfo& info) override {
|
||||
assert(info.db_name == db_name_);
|
||||
assert(IsValidColumnFamilyName(info.cf_name));
|
||||
if (info.file_size) {
|
||||
VerifyFilePath(info.file_path);
|
||||
}
|
||||
assert(info.job_id > 0 || FLAGS_compact_files_one_in > 0);
|
||||
if (info.status.ok() && info.file_size > 0) {
|
||||
assert(info.table_properties.data_size > 0);
|
||||
assert(info.table_properties.raw_key_size > 0);
|
||||
assert(info.table_properties.num_entries > 0);
|
||||
}
|
||||
--num_pending_file_creations_;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -1328,6 +1337,7 @@ class DbStressListener : public EventListener {
|
|||
std::string db_name_;
|
||||
std::vector<DbPath> db_paths_;
|
||||
std::vector<ColumnFamilyDescriptor> column_families_;
|
||||
std::atomic<int> num_pending_file_creations_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue