Skip to content

Commit d16e671

Browse files
committed
[fix](binlog) Fence stale commit TSOs after FE failover
### What problem does this PR solve? Issue Number: None Related PR: apache#67181, apache#67594 Problem Summary: A new FE master previously waited for all pre-failover transactions, including ordinary PREPARED transactions that could remain open until timeout. Publish a monotonic per-instance TSO fence after persisting the new allocation window, reject stale binlog commits in Meta Service, retry them with the new master's TSO, and recover only pre-fence COMMITTED TSO transactions. ### Release note Fence stale binlog transaction commit TSOs across FE master failover and remove the fixed recovery delay and PREPARED-transaction wait. ### Check List (For Author) - Test: Unit Test - FE TSO service/tracker and cloud transaction manager tests - Cloud Meta Service TSO fence/recovery, key, compatibility, and lazy commit tests - Behavior changed: Yes. Binlog commits with a TSO from an older FE master are retried with a fresh TSO; recovery no longer waits for PREPARED or non-TSO transactions. - Does this need documentation: No
1 parent 32432e0 commit d16e671

21 files changed

Lines changed: 825 additions & 134 deletions

‎cloud/src/common/bvars.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ BvarLatencyRecorderWithTag g_bvar_ms_begin_sub_txn("ms", "begin_sub_txn");
4444
BvarLatencyRecorderWithTag g_bvar_ms_abort_sub_txn("ms", "abort_sub_txn");
4545
BvarLatencyRecorderWithTag g_bvar_ms_check_txn_conflict("ms", "check_txn_conflict");
4646
BvarLatencyRecorderWithTag g_bvar_ms_get_tso_recovery_transactions("ms", "get_tso_recovery_transactions");
47+
BvarLatencyRecorderWithTag g_bvar_ms_advance_tso_fence("ms", "advance_tso_fence");
4748
BvarLatencyRecorderWithTag g_bvar_ms_abort_txn_with_coordinator("ms", "abort_txn_with_coordinator");
4849
BvarLatencyRecorderWithTag g_bvar_ms_get_prepare_txn_by_coordinator("ms", "get_prepare_txn_by_coordinator");
4950
BvarLatencyRecorderWithTag g_bvar_ms_clean_txn_label("ms", "clean_txn_label");
@@ -502,6 +503,8 @@ mBvarInt64Adder g_bvar_rpc_kv_get_prepare_txn_by_coordinator_get_counter("rpc_kv
502503
// check_txn_conflict
503504
mBvarInt64Adder g_bvar_rpc_kv_check_txn_conflict_get_counter("rpc_kv_check_txn_conflict_get_counter",{"instance_id"});
504505
mBvarInt64Adder g_bvar_rpc_kv_get_tso_recovery_transactions_get_counter("rpc_kv_get_tso_recovery_transactions_get_counter",{"instance_id"});
506+
mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_get_counter("rpc_kv_advance_tso_fence_get_counter",{"instance_id"});
507+
mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_put_counter("rpc_kv_advance_tso_fence_put_counter",{"instance_id"});
505508
// clean_txn_label
506509
mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_get_counter("rpc_kv_clean_txn_label_get_counter",{"instance_id"});
507510
mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_put_counter("rpc_kv_clean_txn_label_put_counter",{"instance_id"});
@@ -713,6 +716,8 @@ mBvarInt64Adder g_bvar_rpc_kv_get_prepare_txn_by_coordinator_get_bytes("rpc_kv_g
713716
// check_txn_conflict
714717
mBvarInt64Adder g_bvar_rpc_kv_check_txn_conflict_get_bytes("rpc_kv_check_txn_conflict_get_bytes",{"instance_id"});
715718
mBvarInt64Adder g_bvar_rpc_kv_get_tso_recovery_transactions_get_bytes("rpc_kv_get_tso_recovery_transactions_get_bytes",{"instance_id"});
719+
mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_get_bytes("rpc_kv_advance_tso_fence_get_bytes",{"instance_id"});
720+
mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_put_bytes("rpc_kv_advance_tso_fence_put_bytes",{"instance_id"});
716721
// clean_txn_label
717722
mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_get_bytes("rpc_kv_clean_txn_label_get_bytes",{"instance_id"});
718723
mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_put_bytes("rpc_kv_clean_txn_label_put_bytes",{"instance_id"});

‎cloud/src/common/bvars.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ extern BvarLatencyRecorderWithTag g_bvar_ms_get_current_max_txn_id;
554554
extern BvarLatencyRecorderWithTag g_bvar_ms_create_meta_sync_point;
555555
extern BvarLatencyRecorderWithTag g_bvar_ms_check_txn_conflict;
556556
extern BvarLatencyRecorderWithTag g_bvar_ms_get_tso_recovery_transactions;
557+
extern BvarLatencyRecorderWithTag g_bvar_ms_advance_tso_fence;
557558
extern BvarLatencyRecorderWithTag g_bvar_ms_abort_txn_with_coordinator;
558559
extern BvarLatencyRecorderWithTag g_bvar_ms_get_prepare_txn_by_coordinator;
559560
extern BvarLatencyRecorderWithTag g_bvar_ms_begin_sub_txn;
@@ -909,6 +910,8 @@ extern mBvarInt64Adder g_bvar_rpc_kv_abort_txn_with_coordinator_get_counter;
909910
extern mBvarInt64Adder g_bvar_rpc_kv_get_prepare_txn_by_coordinator_get_counter;
910911
extern mBvarInt64Adder g_bvar_rpc_kv_check_txn_conflict_get_counter;
911912
extern mBvarInt64Adder g_bvar_rpc_kv_get_tso_recovery_transactions_get_counter;
913+
extern mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_get_counter;
914+
extern mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_put_counter;
912915
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_get_counter;
913916
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_put_counter;
914917
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_del_counter;
@@ -1053,6 +1056,8 @@ extern mBvarInt64Adder g_bvar_rpc_kv_abort_txn_with_coordinator_get_bytes;
10531056
extern mBvarInt64Adder g_bvar_rpc_kv_get_prepare_txn_by_coordinator_get_bytes;
10541057
extern mBvarInt64Adder g_bvar_rpc_kv_check_txn_conflict_get_bytes;
10551058
extern mBvarInt64Adder g_bvar_rpc_kv_get_tso_recovery_transactions_get_bytes;
1059+
extern mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_get_bytes;
1060+
extern mBvarInt64Adder g_bvar_rpc_kv_advance_tso_fence_put_bytes;
10561061
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_get_bytes;
10571062
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_put_bytes;
10581063
extern mBvarInt64Adder g_bvar_rpc_kv_clean_txn_label_del_bytes;

‎cloud/src/meta-service/meta_service.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ class MetaServiceImpl : public cloud::MetaService {
150150
GetTsoRecoveryTransactionsResponse* response,
151151
::google::protobuf::Closure* done) override;
152152

153+
void advance_tso_fence(::google::protobuf::RpcController* controller,
154+
const AdvanceTsoFenceRequest* request, AdvanceTsoFenceResponse* response,
155+
::google::protobuf::Closure* done) override;
156+
153157
void abort_txn_with_coordinator(::google::protobuf::RpcController* controller,
154158
const AbortTxnWithCoordinatorRequest* request,
155159
AbortTxnWithCoordinatorResponse* response,
@@ -632,6 +636,12 @@ class MetaServiceProxy final : public MetaService {
632636
done);
633637
}
634638

639+
void advance_tso_fence(::google::protobuf::RpcController* controller,
640+
const AdvanceTsoFenceRequest* request, AdvanceTsoFenceResponse* response,
641+
::google::protobuf::Closure* done) override {
642+
call_impl(&cloud::MetaService::advance_tso_fence, controller, request, response, done);
643+
}
644+
635645
void abort_txn_with_coordinator(::google::protobuf::RpcController* controller,
636646
const AbortTxnWithCoordinatorRequest* request,
637647
AbortTxnWithCoordinatorResponse* response,

‎cloud/src/meta-service/meta_service_helper.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ inline std::pair<MetaServiceCode, std::string> resolve_response_code_and_msg(Met
6161
"[TXN_ALREADY_COMMITED will be converted to code=UNDEFINED_ERR for old version "
6262
"clients]";
6363
return {MetaServiceCode::UNDEFINED_ERR, std::move(msg)};
64+
case MetaServiceCode::TXN_COMMIT_TSO_FENCED:
65+
msg += std::string((msg.empty() ? "" : ", ")) +
66+
"[TXN_COMMIT_TSO_FENCED will be converted to code=UNDEFINED_ERR for old "
67+
"version clients]";
68+
return {MetaServiceCode::UNDEFINED_ERR, std::move(msg)};
6469
default:
6570
return {code, std::move(msg)};
6671
}

‎cloud/src/meta-service/meta_service_txn.cpp‎

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,39 @@ static void append_table_stream_commit_size_error(TxnErrorCode err, std::string&
127127
}
128128
}
129129

130+
static bool check_txn_commit_tso_fence(Transaction* txn, const std::string& instance_id,
131+
int64_t commit_tso, CommitTxnResponse* response,
132+
MetaServiceCode& code, std::string& msg) {
133+
if (commit_tso <= 0) {
134+
return true;
135+
}
136+
137+
std::string value;
138+
TxnErrorCode err = txn->get(txn_tso_fence_key({instance_id}), &value);
139+
if (err == TxnErrorCode::TXN_KEY_NOT_FOUND) {
140+
return true;
141+
}
142+
if (err != TxnErrorCode::TXN_OK) {
143+
code = cast_as<ErrCategory::READ>(err);
144+
msg = fmt::format("failed to read TSO fence, err={}", err);
145+
return false;
146+
}
147+
148+
TxnTsoFencePB fence;
149+
if (!fence.ParseFromString(value) || !fence.has_fence_tso() || fence.fence_tso() <= 0) {
150+
code = MetaServiceCode::PROTOBUF_PARSE_ERR;
151+
msg = "failed to parse TSO fence";
152+
return false;
153+
}
154+
if (commit_tso <= fence.fence_tso()) {
155+
response->set_tso_fence(fence.fence_tso());
156+
code = MetaServiceCode::TXN_COMMIT_TSO_FENCED;
157+
msg = fmt::format("commit TSO {} is fenced by {}", commit_tso, fence.fence_tso());
158+
return false;
159+
}
160+
return true;
161+
}
162+
130163
class TableStreamUpdateTxnContext {
131164
public:
132165
TableStreamUpdateTxnContext(Transaction* txn, const std::string& instance_id,
@@ -1911,6 +1944,11 @@ void MetaServiceImpl::commit_txn_immediately(
19111944
return;
19121945
}
19131946

1947+
if (txn_info.status() != TxnStatusPB::TXN_STATUS_COMMITTED &&
1948+
!check_txn_commit_tso_fence(txn.get(), instance_id, commit_tso, response, code, msg)) {
1949+
return;
1950+
}
1951+
19141952
MultiVersionStatus table_stream_multi_version_status =
19151953
MultiVersionStatus::MULTI_VERSION_DISABLED;
19161954
if (!request->table_stream_updates().empty()) {
@@ -2743,6 +2781,11 @@ void MetaServiceImpl::commit_txn_eventually(
27432781
return;
27442782
}
27452783

2784+
if (txn_info.status() != TxnStatusPB::TXN_STATUS_COMMITTED &&
2785+
!check_txn_commit_tso_fence(txn.get(), instance_id, commit_tso, response, code, msg)) {
2786+
return;
2787+
}
2788+
27462789
auto now_time = system_clock::now();
27472790
uint64_t commit_time = duration_cast<milliseconds>(now_time.time_since_epoch()).count();
27482791
if ((txn_info.prepare_time() + txn_info.timeout_ms()) < commit_time) {
@@ -3143,6 +3186,11 @@ void MetaServiceImpl::commit_txn_with_sub_txn(const CommitTxnRequest* request,
31433186
return;
31443187
}
31453188

3189+
if (txn_info.status() != TxnStatusPB::TXN_STATUS_COMMITTED &&
3190+
!check_txn_commit_tso_fence(txn.get(), instance_id, commit_tso, response, code, msg)) {
3191+
return;
3192+
}
3193+
31463194
LOG(INFO) << "txn_id=" << txn_id << " txn_info=" << txn_info.ShortDebugString();
31473195

31483196
AnnotateTag txn_tag("txn_id", txn_id);
@@ -4724,12 +4772,76 @@ std::string get_txn_info_key_from_txn_running_key(std::string_view txn_running_k
47244772
return conflict_txn_info_key;
47254773
}
47264774

4775+
void MetaServiceImpl::advance_tso_fence(::google::protobuf::RpcController* controller,
4776+
const AdvanceTsoFenceRequest* request,
4777+
AdvanceTsoFenceResponse* response,
4778+
::google::protobuf::Closure* done) {
4779+
RPC_PREPROCESS(advance_tso_fence, get, put);
4780+
if (!request->has_proposed_fence_tso() || request->proposed_fence_tso() <= 0) {
4781+
code = MetaServiceCode::INVALID_ARGUMENT;
4782+
msg = "invalid proposed TSO fence";
4783+
return;
4784+
}
4785+
instance_id = get_instance_id(resource_mgr_, request->cloud_unique_id());
4786+
if (instance_id.empty()) {
4787+
code = MetaServiceCode::INVALID_ARGUMENT;
4788+
msg = "cannot find instance_id for TSO fence";
4789+
return;
4790+
}
4791+
RPC_RATE_LIMIT(advance_tso_fence)
4792+
4793+
TxnErrorCode err = txn_kv_->create_txn(&txn);
4794+
if (err != TxnErrorCode::TXN_OK) {
4795+
code = cast_as<ErrCategory::CREATE>(err);
4796+
msg = "failed to create TSO fence transaction";
4797+
return;
4798+
}
4799+
4800+
const std::string key = txn_tso_fence_key({instance_id});
4801+
std::string value;
4802+
err = txn->get(key, &value);
4803+
int64_t current_fence_tso = 0;
4804+
if (err == TxnErrorCode::TXN_OK) {
4805+
TxnTsoFencePB fence;
4806+
if (!fence.ParseFromString(value) || !fence.has_fence_tso() || fence.fence_tso() <= 0) {
4807+
code = MetaServiceCode::PROTOBUF_PARSE_ERR;
4808+
msg = "failed to parse TSO fence";
4809+
return;
4810+
}
4811+
current_fence_tso = fence.fence_tso();
4812+
} else if (err != TxnErrorCode::TXN_KEY_NOT_FOUND) {
4813+
code = cast_as<ErrCategory::READ>(err);
4814+
msg = "failed to read TSO fence";
4815+
return;
4816+
}
4817+
4818+
const int64_t effective_fence_tso = std::max(current_fence_tso, request->proposed_fence_tso());
4819+
if (effective_fence_tso > current_fence_tso) {
4820+
TxnTsoFencePB fence;
4821+
fence.set_fence_tso(effective_fence_tso);
4822+
if (!fence.SerializeToString(&value)) {
4823+
code = MetaServiceCode::PROTOBUF_SERIALIZE_ERR;
4824+
msg = "failed to serialize TSO fence";
4825+
return;
4826+
}
4827+
txn->put(key, value);
4828+
err = txn->commit();
4829+
if (err != TxnErrorCode::TXN_OK) {
4830+
code = cast_as<ErrCategory::COMMIT>(err);
4831+
msg = "failed to commit TSO fence";
4832+
return;
4833+
}
4834+
}
4835+
response->set_tso_fence(effective_fence_tso);
4836+
}
4837+
47274838
void MetaServiceImpl::get_tso_recovery_transactions(
47284839
::google::protobuf::RpcController* controller,
47294840
const GetTsoRecoveryTransactionsRequest* request,
47304841
GetTsoRecoveryTransactionsResponse* response, ::google::protobuf::Closure* done) {
47314842
RPC_PREPROCESS(get_tso_recovery_transactions, get);
4732-
if (request->end_txn_id() <= 0 || request->batch_size() <= 0 || request->batch_size() > 1000) {
4843+
if (request->end_txn_id() <= 0 || request->batch_size() <= 0 || request->batch_size() > 1000 ||
4844+
request->tso_fence() <= 0) {
47334845
code = MetaServiceCode::INVALID_ARGUMENT;
47344846
msg = "invalid TSO recovery transaction bound or batch size";
47354847
return;
@@ -4809,15 +4921,17 @@ void MetaServiceImpl::get_tso_recovery_transactions(
48094921
msg = "invalid TSO recovery transaction identity or tables";
48104922
return;
48114923
}
4924+
if (info.status() != TxnStatusPB::TXN_STATUS_COMMITTED || !info.has_commit_tso() ||
4925+
info.commit_tso() <= 0 || info.commit_tso() > request->tso_fence()) {
4926+
continue;
4927+
}
48124928
// Recovery needs identities and visibility boundaries, not commit attachments.
48134929
auto* recovered = response->add_txn_infos();
48144930
recovered->set_db_id(db_id);
48154931
recovered->set_txn_id(txn_id);
48164932
recovered->mutable_table_ids()->CopyFrom(info.table_ids());
48174933
recovered->set_status(info.status());
4818-
if (info.has_commit_tso()) {
4819-
recovered->set_commit_tso(info.commit_tso());
4820-
}
4934+
recovered->set_commit_tso(info.commit_tso());
48214935
}
48224936
begin_key.push_back('\x00');
48234937
response->set_next_start_key(it->more() ? begin_key : "");

‎cloud/src/meta-store/keys.cpp‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const char* TXN_KEY_INFIX_LABEL = "txn_label";
4242
static const char* TXN_KEY_INFIX_INFO = "txn_info";
4343
static const char* TXN_KEY_INFIX_INDEX = "txn_index";
4444
static const char* TXN_KEY_INFIX_RUNNING = "txn_running";
45+
static const char* TXN_KEY_INFIX_TSO_FENCE = "tso_fence";
4546

4647
static const char* PARTITION_VERSION_KEY_INFIX = "partition";
4748
static const char* TABLE_VERSION_KEY_INFIX = "table";
@@ -145,7 +146,7 @@ static void encode_prefix(const T& t, std::string* key) {
145146
// Input type T must be one of the following, add if needed
146147
static_assert(check_types_v<T,
147148
InstanceKeyInfo,
148-
TxnLabelKeyInfo, TxnInfoKeyInfo, TxnIndexKeyInfo, TxnRunningKeyInfo,
149+
TxnLabelKeyInfo, TxnInfoKeyInfo, TxnIndexKeyInfo, TxnRunningKeyInfo, TxnTsoFenceKeyInfo,
149150
MetaRowsetKeyInfo, MetaRowsetTmpKeyInfo, MetaTabletKeyInfo, MetaTabletIdxKeyInfo, MetaSchemaKeyInfo,
150151
TableStreamOffsetKeyInfo,
151152
MetaDeleteBitmapInfo, MetaDeleteBitmapUpdateLockInfo, MetaPendingDeleteBitmapInfo, PartitionVersionKeyInfo,
@@ -163,7 +164,8 @@ static void encode_prefix(const T& t, std::string* key) {
163164
} else if constexpr (std::is_same_v<T, TxnLabelKeyInfo>
164165
|| std::is_same_v<T, TxnInfoKeyInfo>
165166
|| std::is_same_v<T, TxnIndexKeyInfo>
166-
|| std::is_same_v<T, TxnRunningKeyInfo>) {
167+
|| std::is_same_v<T, TxnRunningKeyInfo>
168+
|| std::is_same_v<T, TxnTsoFenceKeyInfo>) {
167169
encode_bytes(TXN_KEY_PREFIX, key);
168170
} else if constexpr (std::is_same_v<T, MetaRowsetKeyInfo>
169171
|| std::is_same_v<T, MetaRowsetTmpKeyInfo>
@@ -259,6 +261,11 @@ void txn_running_key(const TxnRunningKeyInfo& in, std::string* out) {
259261
encode_int64(std::get<2>(in), out); // txn_id
260262
}
261263

264+
void txn_tso_fence_key(const TxnTsoFenceKeyInfo& in, std::string* out) {
265+
encode_prefix(in, out); // 0x01 "txn" ${instance_id}
266+
encode_bytes(TXN_KEY_INFIX_TSO_FENCE, out); // "tso_fence"
267+
}
268+
262269
//==============================================================================
263270
// Version keys
264271
//==============================================================================

‎cloud/src/meta-store/keys.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ using TxnIndexKeyInfo = BasicKeyInfo<__LINE__ , std::tuple<std::string, in
165165
// 0:instance_id 1:db_id 2:txn_id
166166
using TxnRunningKeyInfo = BasicKeyInfo<__LINE__ , std::tuple<std::string, int64_t, int64_t>>;
167167

168+
// 0:instance_id
169+
using TxnTsoFenceKeyInfo = BasicKeyInfo<__LINE__ , std::tuple<std::string>>;
170+
168171
// 0:instance_id 1:db_id 2:tbl_id 3:partition_id
169172
using PartitionVersionKeyInfo = BasicKeyInfo<__LINE__ , std::tuple<std::string, int64_t, int64_t, int64_t>>;
170173

@@ -361,10 +364,12 @@ void txn_label_key(const TxnLabelKeyInfo& in, std::string* out);
361364
void txn_info_key(const TxnInfoKeyInfo& in, std::string* out);
362365
void txn_index_key(const TxnIndexKeyInfo& in, std::string* out);
363366
void txn_running_key(const TxnRunningKeyInfo& in, std::string* out);
367+
void txn_tso_fence_key(const TxnTsoFenceKeyInfo& in, std::string* out);
364368
static inline std::string txn_label_key(const TxnLabelKeyInfo& in) { std::string s; txn_label_key(in, &s); return s; }
365369
static inline std::string txn_info_key(const TxnInfoKeyInfo& in) { std::string s; txn_info_key(in, &s); return s; }
366370
static inline std::string txn_index_key(const TxnIndexKeyInfo& in) { std::string s; txn_index_key(in, &s); return s; }
367371
static inline std::string txn_running_key(const TxnRunningKeyInfo& in) { std::string s; txn_running_key(in, &s); return s; }
372+
static inline std::string txn_tso_fence_key(const TxnTsoFenceKeyInfo& in) { std::string s; txn_tso_fence_key(in, &s); return s; }
368373

369374
std::string version_key_prefix(std::string_view instance_id);
370375
void partition_version_key(const PartitionVersionKeyInfo& in, std::string* out);

‎cloud/test/keys_test.cpp‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,23 @@ TEST(KeysTest, TxnKeysTest) {
545545

546546
ASSERT_GT(encoded_txn_running_key1, encoded_txn_running_key0);
547547
}
548+
549+
// 0x01 "txn" ${instance_id} "tso_fence" -> TxnTsoFencePB
550+
{
551+
std::string encoded_key = txn_tso_fence_key({instance_id});
552+
std::string_view key_sv(encoded_key);
553+
std::string decoded_prefix;
554+
std::string decoded_instance_id;
555+
std::string decoded_infix;
556+
remove_user_space_prefix(&key_sv);
557+
ASSERT_EQ(decode_bytes(&key_sv, &decoded_prefix), 0);
558+
ASSERT_EQ(decode_bytes(&key_sv, &decoded_instance_id), 0);
559+
ASSERT_EQ(decode_bytes(&key_sv, &decoded_infix), 0);
560+
ASSERT_TRUE(key_sv.empty());
561+
EXPECT_EQ("txn", decoded_prefix);
562+
EXPECT_EQ(instance_id, decoded_instance_id);
563+
EXPECT_EQ("tso_fence", decoded_infix);
564+
}
548565
}
549566

550567
TEST(KeysTest, RecycleKeysTest) {

‎cloud/test/meta_service_helper_test.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ TEST(MetaServiceHelperTest, ResponseStatusCoversEveryMetaServiceCode) {
413413

414414
expect_legacy_fallback_response_status(covered_codes, MetaServiceCode::TXN_ALREADY_COMMITED,
415415
LegacyFallbackCode::UNDEFINED_ERR);
416+
expect_legacy_fallback_response_status(covered_codes, MetaServiceCode::TXN_COMMIT_TSO_FENCED,
417+
LegacyFallbackCode::UNDEFINED_ERR);
416418
EXPECT_EQ(covered_codes.size(),
417419
static_cast<size_t>(MetaServiceCode_descriptor()->value_count()))
418420
<< "A new MetaServiceCode was added. Map it to a LegacyFallbackCode in "

0 commit comments

Comments
 (0)