@@ -681,6 +681,10 @@ void internal_create_tablet(const CreateTabletsRequest* request, MetaServiceCode
681681 }
682682 txn->put (rs_key, rs_val);
683683 if (is_versioned_write) {
684+ std::string meta_rowset_key = versioned::meta_rowset_key (
685+ {instance_id, tablet_id, first_rowset->rowset_id_v2 ()});
686+ blob_put (txn.get (), meta_rowset_key, rs_val, 0 );
687+
684688 std::string rowset_ref_count_key = versioned::data_rowset_ref_count_key (
685689 {instance_id, tablet_id, first_rowset->rowset_id_v2 ()});
686690 txn->atomic_add (rowset_ref_count_key, 1 );
@@ -693,9 +697,11 @@ void internal_create_tablet(const CreateTabletsRequest* request, MetaServiceCode
693697 return ;
694698 }
695699 LOG (INFO) << " put first versioned rowset meta, tablet_id=" << tablet_id
700+ << " rowset_id=" << first_rowset->rowset_id_v2 ()
696701 << " end_version=" << first_rowset->end_version ()
697702 << " key=" << hex (versioned_rs_key)
698- << " rowset_ref_count_key=" << hex (rowset_ref_count_key);
703+ << " rowset_ref_count_key=" << hex (rowset_ref_count_key)
704+ << " meta_rowset_key=" << hex (meta_rowset_key);
699705 }
700706
701707 tablet_meta.clear_rs_metas (); // Strip off rowset meta
@@ -2697,20 +2703,38 @@ void MetaServiceImpl::commit_rowset(::google::protobuf::RpcController* controlle
26972703 rowset_meta.set_allocated_tablet_schema (nullptr );
26982704 }
26992705
2706+ auto recycle_rs_key = recycle_rowset_key ({instance_id, tablet_id, rowset_id});
2707+ txn->remove (recycle_rs_key);
2708+
2709+ DCHECK_GT (rowset_meta.txn_expiration (), 0 );
2710+ auto tmp_rs_val = rowset_meta.SerializeAsString ();
2711+ txn->put (tmp_rs_key, tmp_rs_val);
2712+
27002713 if (is_version_write_enabled (instance_id)) {
27012714 std::string rowset_ref_count_key =
27022715 versioned::data_rowset_ref_count_key ({instance_id, tablet_id, rowset_id});
27032716 LOG (INFO) << " add rowset ref count key, instance_id=" << instance_id
27042717 << " key=" << hex (rowset_ref_count_key);
27052718 txn->atomic_add (rowset_ref_count_key, 1 );
2706- }
27072719
2708- auto recycle_rs_key = recycle_rowset_key ({instance_id, tablet_id, rowset_id});
2709- txn->remove (recycle_rs_key);
2720+ // Recycler uses end_version to check if the meta_rowset_compact_key or
2721+ // meta_rowset_load_key exists.
2722+ // The end_version is not set if rowset is committed by load, later commit_txn will write
2723+ // this key again to save end_version.
2724+ std::string meta_rowset_key =
2725+ versioned::meta_rowset_key ({instance_id, tablet_id, rowset_id});
2726+ if (config::enable_recycle_rowset_strip_key_bounds) {
2727+ doris::RowsetMetaCloudPB rowset_meta_copy = rowset_meta;
2728+ // Strip key bounds to shrink operation log for ts compaction recycle entries
2729+ rowset_meta_copy.clear_segments_key_bounds ();
2730+ rowset_meta_copy.clear_segments_key_bounds_truncated ();
2731+ blob_put (txn.get (), meta_rowset_key, rowset_meta_copy.SerializeAsString (), 0 );
2732+ } else {
2733+ blob_put (txn.get (), meta_rowset_key, tmp_rs_val, 0 );
2734+ }
2735+ LOG (INFO) << " put versioned meta_rowset_key=" << hex (meta_rowset_key);
2736+ }
27102737
2711- DCHECK_GT (rowset_meta.txn_expiration (), 0 );
2712- auto tmp_rs_val = rowset_meta.SerializeAsString ();
2713- txn->put (tmp_rs_key, tmp_rs_val);
27142738 std::size_t segment_key_bounds_bytes = get_segments_key_bounds_bytes (rowset_meta);
27152739 LOG (INFO) << " put tmp_rs_key " << hex (tmp_rs_key) << " delete recycle_rs_key "
27162740 << hex (recycle_rs_key) << " value_size " << tmp_rs_val.size () << " txn_id "
0 commit comments