@@ -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 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 wait_for_commit Wait committed lsn reaches compact_lsn. Default is true, false means the snapshot will be
980+ * triggered based on its latest committed lsn and the log compaction depends on min(snapshot_lsn, compact_lsn)
981+ *
982+ * Recommendation:
983+ * - Please keep wait_for_commit=true to make sure the compact_lsn <= committed_lsn when snapshot is created. If you
984+ * just want to trigger a snapshot manually or want to update the compact_lsn (already less than committed_lsn) for
985+ * log compaction, you can set wait_for_commit=false.
986+ * - wait_for_commit=true might cause the caller blocked for a while until the committed_lsn reaches compact_lsn.
987+ * Please keep in mind and take action if this function costs too long.
988+ */
989+ void trigger_snapshot_creation (int32_t pg_id, int64_t compact_lsn, 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