@@ -54,7 +54,8 @@ class HSHomeObject : public HomeObjectImpl {
5454 uint32_t _hs_reserved_blks = 0 ;
5555
5656 // / Overridable Helpers
57- ShardManager::AsyncResult< ShardInfo > _create_shard (pg_id_t , uint64_t size_bytes, std::string meta, trace_id_t tid) override ;
57+ ShardManager::AsyncResult< ShardInfo > _create_shard (pg_id_t , uint64_t size_bytes, std::string meta,
58+ trace_id_t tid) override ;
5859 ShardManager::AsyncResult< ShardInfo > _seal_shard (ShardInfo const &, trace_id_t tid) override ;
5960
6061 BlobManager::AsyncResult< blob_id_t > _put_blob (ShardInfo const &, Blob&&, trace_id_t tid) override ;
@@ -196,7 +197,7 @@ class HSHomeObject : public HomeObjectImpl {
196197 };
197198
198199 struct shard_info_superblk : DataHeader {
199- // This version is a common version of DataHeader, each derived struct can have its own version.
200+ // This version is a common version of DataHeader, each derived struct can have its own version.
200201 static constexpr uint8_t shard_sb_version = 0x02 ;
201202
202203 uint8_t sb_version{shard_sb_version};
@@ -394,6 +395,8 @@ class HSHomeObject : public HomeObjectImpl {
394395
395396 void yield_leadership_to_follower () const ;
396397
398+ void trigger_snapshot_creation (int64_t compact_lsn, bool is_async, bool wait_for_commit) const ;
399+
397400 /* *
398401 * Returns all shards
399402 */
@@ -437,7 +440,7 @@ class HSHomeObject : public HomeObjectImpl {
437440 uint32_t data_offset; // Offset of actual data blob stored after the metadata
438441 uint32_t user_key_size; // Actual size of the user key.
439442 uint8_t user_key[max_user_key_length + 1 ]{};
440- uint8_t padding[2956 ]{}; // data_block_size is 4K, so total size of BlobHeader is 4096 bytes
443+ uint8_t padding[2956 ]{}; // data_block_size is 4K, so total size of BlobHeader is 4096 bytes
441444
442445 std::optional< std::string > get_user_key () const {
443446 if (user_key_size > max_user_key_length) { return std::nullopt ; }
@@ -969,6 +972,22 @@ class HSHomeObject : public HomeObjectImpl {
969972 */
970973 void yield_pg_leadership_to_follower (int32_t pg_id = 1 );
971974
975+ /* *
976+ * @brief Manually trigger a snapshot creation.
977+ * @param compact_lsn Expected compact up to LSN. Default is -1, meaning it depends directly on the current HS
978+ * status.
979+ * @param is_async Trigger mode. Default is true, meaning an async snapshot is triggered on the next earliest
980+ * committed log. If false, a snapshot is triggered immediately based on the latest committed log.
981+ * @param wait_for_commit Wait committed lsn reaches compact_lsn. Default is true, false means the snapshot will be
982+ * triggered based on its latest committed lsn and the log compaction depends on min(snapshot_lsn, compact_lsn)
983+ *
984+ * Recommendation:
985+ * - If there is continuous traffic, it is recommended to set is_async=true. This only sets a flag, relying on
986+ * subsequent commits to trigger the snapshot asynchronously, making it more lightweight.
987+ * - If there is no continuous traffic, set is_async=false to trigger a snapshot immediately.
988+ */
989+ void trigger_snapshot_creation (int32_t pg_id, int64_t compact_lsn, bool is_async, bool wait_for_commit);
990+
972991 // Blob manager related.
973992 void on_blob_message_rollback (int64_t lsn, sisl::blob const & header, sisl::blob const & key,
974993 cintrusive< homestore::repl_req_ctx >& hs_ctx);
0 commit comments