Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve](mow) refactor mow update lock for compaction to reduce txn conflict #48024

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cloud/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ CONF_mInt64(max_s3_client_retry, "10");

// Max byte getting delete bitmap can return, default is 1GB
CONF_mInt64(max_get_delete_bitmap_byte, "1073741824");
// retry configs of remove_delete_bitmap_update_lock txn_conflict
CONF_Bool(delete_bitmap_enable_retry_txn_conflict, "true");

// Max byte txn commit when updating delete bitmap, default is 7MB.
// Because the size of one fdb transaction can't exceed 10MB, and
Expand Down
14 changes: 13 additions & 1 deletion cloud/src/meta-service/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static const char* STATS_KEY_PREFIX = "stats";
static const char* JOB_KEY_PREFIX = "job";
static const char* COPY_KEY_PREFIX = "copy";
static const char* VAULT_KEY_PREFIX = "storage_vault";
static const char* MOW_KEY_PREFIX = "mow";

// Infix
static const char* TXN_KEY_INFIX_LABEL = "txn_label";
Expand All @@ -51,6 +52,7 @@ static const char* META_KEY_INFIX_SCHEMA = "schema";
static const char* META_KEY_INFIX_DELETE_BITMAP = "delete_bitmap";
static const char* META_KEY_INFIX_DELETE_BITMAP_LOCK = "delete_bitmap_lock";
static const char* META_KEY_INFIX_DELETE_BITMAP_PENDING = "delete_bitmap_pending";
static const char* META_KEY_INFIX_MOW_TABLET_COMPACTION = "mow_tablet_comp";
static const char* META_KEY_INFIX_SCHEMA_DICTIONARY = "tablet_schema_pb_dict";

static const char* RECYCLE_KEY_INFIX_INDEX = "index";
Expand Down Expand Up @@ -115,7 +117,8 @@ static void encode_prefix(const T& t, std::string* key) {
RecycleIndexKeyInfo, RecyclePartKeyInfo, RecycleRowsetKeyInfo, RecycleTxnKeyInfo, RecycleStageKeyInfo,
StatsTabletKeyInfo, TableVersionKeyInfo,
JobTabletKeyInfo, JobRecycleKeyInfo, RLJobProgressKeyInfo,
CopyJobKeyInfo, CopyFileKeyInfo, StorageVaultKeyInfo, MetaSchemaPBDictionaryInfo>);
CopyJobKeyInfo, CopyFileKeyInfo, StorageVaultKeyInfo, MetaSchemaPBDictionaryInfo,
MowTabletCompactionInfo>);

key->push_back(CLOUD_USER_KEY_SPACE01);
// Prefixes for key families
Expand Down Expand Up @@ -156,6 +159,8 @@ static void encode_prefix(const T& t, std::string* key) {
encode_bytes(COPY_KEY_PREFIX, key);
} else if constexpr (std::is_same_v<T, StorageVaultKeyInfo>) {
encode_bytes(VAULT_KEY_PREFIX, key);
} else if constexpr(std::is_same_v<T, MowTabletCompactionInfo>) {
encode_bytes(MOW_KEY_PREFIX, key);
} else {
// This branch mean to be unreachable, add an assert(false) here to
// prevent missing branch match.
Expand Down Expand Up @@ -497,6 +502,13 @@ std::string system_meta_service_encryption_key_info_key() {
// Other keys
//==============================================================================

void mow_tablet_compaction_key(const MowTabletCompactionInfo& in, std::string* out) {
encode_prefix(in, out); // 0x01 "mow" ${instance_id}
encode_bytes(META_KEY_INFIX_MOW_TABLET_COMPACTION, out); // "mow_tablet_comp"
encode_int64(std::get<1>(in), out); // table_id
encode_int64(std::get<2>(in), out); // initiator
}

//==============================================================================
// Decode keys
//==============================================================================
Expand Down
5 changes: 4 additions & 1 deletion cloud/src/meta-service/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ using StorageVaultKeyInfo = BasicKeyInfo<26, std::tuple<std::string, std::string
using TableVersionKeyInfo = BasicKeyInfo<27, std::tuple<std::string, int64_t, int64_t>>;
// 0:instance_id 1:index_id
using MetaSchemaPBDictionaryInfo = BasicKeyInfo<28 , std::tuple<std::string, int64_t>>;

// 0:instance_id 1:table_id 2:initiator
using MowTabletCompactionInfo = BasicKeyInfo<29 , std::tuple<std::string, int64_t, int64_t>>;

void instance_key(const InstanceKeyInfo& in, std::string* out);
static inline std::string instance_key(const InstanceKeyInfo& in) { std::string s; instance_key(in, &s); return s; }
Expand Down Expand Up @@ -224,6 +225,7 @@ void meta_delete_bitmap_key(const MetaDeleteBitmapInfo& in, std::string* out);
void meta_delete_bitmap_update_lock_key(const MetaDeleteBitmapUpdateLockInfo& in, std::string* out);
void meta_pending_delete_bitmap_key(const MetaPendingDeleteBitmapInfo& in, std::string* out);
void meta_schema_pb_dictionary_key(const MetaSchemaPBDictionaryInfo& in, std::string* out);
void mow_tablet_compaction_key(const MowTabletCompactionInfo& in, std::string* out);
static inline std::string meta_rowset_key(const MetaRowsetKeyInfo& in) { std::string s; meta_rowset_key(in, &s); return s; }
static inline std::string meta_rowset_tmp_key(const MetaRowsetTmpKeyInfo& in) { std::string s; meta_rowset_tmp_key(in, &s); return s; }
static inline std::string meta_tablet_idx_key(const MetaTabletIdxKeyInfo& in) { std::string s; meta_tablet_idx_key(in, &s); return s; }
Expand All @@ -233,6 +235,7 @@ static inline std::string meta_delete_bitmap_key(const MetaDeleteBitmapInfo& in)
static inline std::string meta_delete_bitmap_update_lock_key(const MetaDeleteBitmapUpdateLockInfo& in) { std::string s; meta_delete_bitmap_update_lock_key(in, &s); return s; }
static inline std::string meta_pending_delete_bitmap_key(const MetaPendingDeleteBitmapInfo& in) { std::string s; meta_pending_delete_bitmap_key(in, &s); return s; }
static inline std::string meta_schema_pb_dictionary_key(const MetaSchemaPBDictionaryInfo& in) { std::string s; meta_schema_pb_dictionary_key(in, &s); return s; }
static inline std::string mow_tablet_compaction_key(const MowTabletCompactionInfo& in) { std::string s; mow_tablet_compaction_key(in, &s); return s; }

std::string recycle_key_prefix(std::string_view instance_id);
void recycle_index_key(const RecycleIndexKeyInfo& in, std::string* out);
Expand Down
Loading
Loading