summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYu Zhang <yuzhangyu@fb.com>2024-06-06 17:29:01 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2024-06-06 17:29:01 -0700
commit44aceb88d0de120847719c061aa3a8465daaee48 (patch)
tree038b7c531c59860c9793fecd782705fa15b06899 /include
parent390fc55ba15912751591a4522e701a760b80640a (diff)
Add a OnManualFlushScheduled callback in event listener (#12631)
Summary: As titled. Also added the newest user-defined timestamp into the `MemTableInfo`. This can be a useful info in the callback. Added some unit tests as examples for how users can use two separate approaches to allow manual flush / manual compactions to go through when the user-defined timestamps in memtable only feature is enabled. One approach relies on selectively increase cutoff timestamp in `OnMemtableSeal` callback when it's initiated by a manual flush. Another approach is to increase cutoff timestamp in `OnManualFlushScheduled` callback. The caveats of the approaches are also documented in the unit test. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12631 Reviewed By: ajkr Differential Revision: D58260528 Pulled By: jowlyzhang fbshipit-source-id: bf446d7140affdf124744095e0a179fa6e427532
Diffstat (limited to 'include')
-rw-r--r--include/rocksdb/listener.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/rocksdb/listener.h b/include/rocksdb/listener.h
index 452ae54cd..8911bc299 100644
--- a/include/rocksdb/listener.h
+++ b/include/rocksdb/listener.h
@@ -328,6 +328,15 @@ struct BlobFileGarbageInfo : public BlobFileInfo {
uint64_t garbage_blob_bytes;
};
+struct ManualFlushInfo {
+ // the id of the column family
+ uint32_t cf_id;
+ // the name of the column family
+ std::string cf_name;
+ // Reason that triggered this manual flush
+ FlushReason flush_reason;
+};
+
struct FlushJobInfo {
// the id of the column family
uint32_t cf_id;
@@ -492,6 +501,10 @@ struct MemTableInfo {
uint64_t num_entries;
// Total number of deletes in memtable
uint64_t num_deletes;
+
+ // The newest user-defined timestamps in the memtable. Note this field is
+ // only populated when `persist_user_defined_timestamps` is false.
+ std::string newest_udt;
};
struct ExternalFileIngestionInfo {
@@ -595,6 +608,14 @@ class EventListener : public Customizable {
virtual void OnFlushBegin(DB* /*db*/,
const FlushJobInfo& /*flush_job_info*/) {}
+ // A callback function to RocksDB which will be called after a manual flush
+ // is scheduled. The default implementation is no-op.
+ // The size of the `manual_flush_info` vector should only be bigger than 1 if
+ // the DB enables atomic flush and has more than 1 column families. Its size
+ // should be 1 in all other cases.
+ virtual void OnManualFlushScheduled(
+ DB* /*db*/, const std::vector<ManualFlushInfo>& /*manual_flush_info*/) {}
+
// A callback function for RocksDB which will be called whenever
// a SST file is deleted. Different from OnCompactionCompleted and
// OnFlushCompleted, this callback is designed for external logging