|
|
@ -27,7 +27,9 @@ struct SuperVersionContext { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
autovector<SuperVersion*> superversions_to_free; |
|
|
|
autovector<SuperVersion*> superversions_to_free; |
|
|
|
|
|
|
|
#ifndef ROCKSDB_DISABLE_STALL_NOTIFICATION |
|
|
|
autovector<WriteStallNotification> write_stall_notifications; |
|
|
|
autovector<WriteStallNotification> write_stall_notifications; |
|
|
|
|
|
|
|
#endif |
|
|
|
unique_ptr<SuperVersion> new_superversion; // if nullptr no new superversion
|
|
|
|
unique_ptr<SuperVersion> new_superversion; // if nullptr no new superversion
|
|
|
|
|
|
|
|
|
|
|
|
explicit SuperVersionContext(bool create_superversion = false) |
|
|
|
explicit SuperVersionContext(bool create_superversion = false) |
|
|
@ -38,14 +40,18 @@ struct SuperVersionContext { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline bool HaveSomethingToDelete() const { |
|
|
|
inline bool HaveSomethingToDelete() const { |
|
|
|
return superversions_to_free.size() > 0 || |
|
|
|
#ifndef ROCKSDB_DISABLE_STALL_NOTIFICATION |
|
|
|
write_stall_notifications.size() > 0; |
|
|
|
return !superversions_to_free.empty() || |
|
|
|
|
|
|
|
!write_stall_notifications.empty(); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
return !superversions_to_free.empty(); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PushWriteStallNotification( |
|
|
|
void PushWriteStallNotification( |
|
|
|
WriteStallCondition old_cond, WriteStallCondition new_cond, |
|
|
|
WriteStallCondition old_cond, WriteStallCondition new_cond, |
|
|
|
const std::string& name, const ImmutableCFOptions* ioptions) { |
|
|
|
const std::string& name, const ImmutableCFOptions* ioptions) { |
|
|
|
#ifndef ROCKSDB_LITE |
|
|
|
#if !defined(ROCKSDB_LITE) && !defined(ROCKSDB_DISABLE_STALL_NOTIFICATION) |
|
|
|
WriteStallNotification notif; |
|
|
|
WriteStallNotification notif; |
|
|
|
notif.write_stall_info.cf_name = name; |
|
|
|
notif.write_stall_info.cf_name = name; |
|
|
|
notif.write_stall_info.condition.prev = old_cond; |
|
|
|
notif.write_stall_info.condition.prev = old_cond; |
|
|
@ -57,14 +63,14 @@ struct SuperVersionContext { |
|
|
|
(void)new_cond; |
|
|
|
(void)new_cond; |
|
|
|
(void)name; |
|
|
|
(void)name; |
|
|
|
(void)ioptions; |
|
|
|
(void)ioptions; |
|
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
#endif // !defined(ROCKSDB_LITE) && !defined(ROCKSDB_DISABLE_STALL_NOTIFICATION)
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Clean() { |
|
|
|
void Clean() { |
|
|
|
#ifndef ROCKSDB_LITE |
|
|
|
#if !defined(ROCKSDB_LITE) && !defined(ROCKSDB_DISABLE_STALL_NOTIFICATION) |
|
|
|
// notify listeners on changed write stall conditions
|
|
|
|
// notify listeners on changed write stall conditions
|
|
|
|
for (auto& notif : write_stall_notifications) { |
|
|
|
for (auto& notif : write_stall_notifications) { |
|
|
|
for (auto listener : notif.immutable_cf_options->listeners) { |
|
|
|
for (auto& listener : notif.immutable_cf_options->listeners) { |
|
|
|
listener->OnStallConditionsChanged(notif.write_stall_info); |
|
|
|
listener->OnStallConditionsChanged(notif.write_stall_info); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -78,8 +84,10 @@ struct SuperVersionContext { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
~SuperVersionContext() { |
|
|
|
~SuperVersionContext() { |
|
|
|
assert(write_stall_notifications.size() == 0); |
|
|
|
#ifndef ROCKSDB_DISABLE_STALL_NOTIFICATION |
|
|
|
assert(superversions_to_free.size() == 0); |
|
|
|
assert(write_stall_notifications.empty()); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
assert(superversions_to_free.empty()); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -99,7 +107,7 @@ struct JobContext { |
|
|
|
std::string file_name; |
|
|
|
std::string file_name; |
|
|
|
std::string file_path; |
|
|
|
std::string file_path; |
|
|
|
CandidateFileInfo(std::string name, std::string path) |
|
|
|
CandidateFileInfo(std::string name, std::string path) |
|
|
|
: file_name(std::move(name)), file_path(path) {} |
|
|
|
: file_name(std::move(name)), file_path(std::move(path)) {} |
|
|
|
bool operator==(const CandidateFileInfo& other) const { |
|
|
|
bool operator==(const CandidateFileInfo& other) const { |
|
|
|
return file_name == other.file_name && |
|
|
|
return file_name == other.file_name && |
|
|
|
file_path == other.file_path; |
|
|
|
file_path == other.file_path; |
|
|
|