Skip to content

Commit 7446dbc

Browse files
authored
refactor(meta-server): remove TxnReply::error (#18112)
The `error` field is not used since 1.2.676; and is removed in this commit.
1 parent ba92f69 commit 7446dbc

File tree

9 files changed

+22
-28
lines changed

9 files changed

+22
-28
lines changed

src/meta/api/src/reply.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,8 @@ where T: DeserializeOwned {
3333
}
3434
}
3535

36-
/// Convert txn response to `success` and a series of `TxnOpResponse`.
37-
pub fn txn_reply_to_api_result(
38-
txn_reply: TxnReply,
39-
) -> Result<(bool, Vec<TxnOpResponse>), MetaAPIError> {
40-
if txn_reply.error.is_empty() {
41-
Ok((txn_reply.success, txn_reply.responses))
42-
} else {
43-
let err: MetaAPIError = serde_json::from_str(&txn_reply.error)
44-
.map_err(|e| InvalidReply::new("invalid TxnReply.error", &e))?;
45-
46-
Err(err)
47-
}
36+
pub fn unpack_txn_reply(txn_reply: TxnReply) -> (bool, Vec<TxnOpResponse>) {
37+
(txn_reply.success, txn_reply.responses)
4838
}
4939

5040
#[cfg(test)]

src/meta/api/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use display_more::DisplaySliceExt;
4444
use log::debug;
4545

4646
use crate::kv_app_error::KVAppError;
47-
use crate::reply::txn_reply_to_api_result;
47+
use crate::reply::unpack_txn_reply;
4848

4949
pub const DEFAULT_MGET_SIZE: usize = 256;
5050

@@ -247,7 +247,7 @@ pub async fn send_txn(
247247
) -> Result<(bool, Vec<TxnOpResponse>), MetaError> {
248248
debug!("send txn: {}", txn_req);
249249
let tx_reply = kv_api.transaction(txn_req).await?;
250-
let (succ, responses) = txn_reply_to_api_result(tx_reply)?;
250+
let (succ, responses) = unpack_txn_reply(tx_reply);
251251
debug!("txn success: {}: {}", succ, responses.display_n::<20>());
252252
Ok((succ, responses))
253253
}

src/meta/client/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub static METACLI_COMMIT_SEMVER: LazyLock<Version> = LazyLock::new(|| {
127127
/// - 2024-12-20: since 1.2.676
128128
/// 🖥 server: add `TxnRequest::operations`,
129129
/// to specify a complex bool expression and corresponding operations
130+
/// 🖥 server: no longer use `TxnReply::error`
131+
/// 👥 client: no longer use `TxnReply::error`
130132
///
131133
/// - 2024-12-26: since 1.2.677
132134
/// 🖥 server: add `WatchRequest::initial_flush`,
@@ -139,9 +141,11 @@ pub static METACLI_COMMIT_SEMVER: LazyLock<Version> = LazyLock::new(|| {
139141
/// - 2025-04-15: since 1.2.726
140142
/// 👥 client: requires `1,2.677`.
141143
///
142-
/// - 2025-05-08: since TODO: add version when merged.
144+
/// - 2025-05-08: since 1.2.736
143145
/// 🖥 server: add `WatchResponse::is_initialization`,
144146
///
147+
/// - 2025-06-09: since TODO: update when merged
148+
/// 🖥 server: remove `TxnReply::error`
145149
///
146150
/// Server feature set:
147151
/// ```yaml

src/meta/service/src/api/grpc/grpc_service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,13 @@ impl MetaServiceImpl {
210210
(endpoint, txn_reply)
211211
}
212212
Err(err) => {
213+
network_metrics::incr_request_result(false);
213214
error!("txn request failed: {:?}", err);
214215
return Err(Status::internal(err.to_string()));
215216
}
216217
};
217218

218-
network_metrics::incr_request_result(txn_reply.error.is_empty());
219+
network_metrics::incr_request_result(true);
219220

220221
Ok((endpoint, txn_reply))
221222
}

src/meta/types/proto/meta.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ message TxnReply {
249249
repeated TxnOpResponse responses = 2;
250250

251251
// Not used
252-
string error = 3;
252+
// string error = 3;
253+
reserved 3;
253254

254255
// Identifies which execution path was taken
255256
string execution_path = 4;

src/meta/types/src/proto_display/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,9 @@ impl Display for TxnReply {
224224
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
225225
write!(
226226
f,
227-
"TxnReply{{ success: {}, responses: {}, error: {}}}",
227+
"TxnReply{{ success: {}, responses: {}}}",
228228
self.success,
229229
VecDisplay::new_at_most(&self.responses, 5),
230-
self.error
231230
)
232231
}
233232
}

src/meta/types/src/proto_ext/txn_ext.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ impl pb::TxnReply {
8383
Self {
8484
success: execution_path != "else",
8585
responses: vec![],
86-
error: "".to_string(),
8786
execution_path,
8887
}
8988
}

src/query/management/src/role/role_mgr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::sync::Arc;
1616

1717
use databend_common_base::base::tokio::sync::Mutex;
1818
use databend_common_exception::ErrorCode;
19-
use databend_common_meta_api::reply::txn_reply_to_api_result;
19+
use databend_common_meta_api::reply::unpack_txn_reply;
2020
use databend_common_meta_api::txn_backoff::txn_backoff;
2121
use databend_common_meta_api::txn_cond_seq;
2222
use databend_common_meta_api::txn_op_del;
@@ -370,7 +370,7 @@ impl RoleApi for RoleMgr {
370370
if need_transfer {
371371
let txn_req = TxnRequest::new(condition.clone(), if_then.clone());
372372
let tx_reply = self.kv_api.transaction(txn_req.clone()).await?;
373-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
373+
let (succ, _) = unpack_txn_reply(tx_reply);
374374
debug!(
375375
succ = succ;
376376
"transfer_ownership_to_admin"
@@ -434,7 +434,7 @@ impl RoleApi for RoleMgr {
434434
let txn_req = TxnRequest::new(condition.clone(), if_then.clone());
435435

436436
let tx_reply = self.kv_api.transaction(txn_req.clone()).await?;
437-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
437+
let (succ, _) = unpack_txn_reply(tx_reply);
438438

439439
if succ {
440440
return Ok(());
@@ -519,7 +519,7 @@ impl RoleApi for RoleMgr {
519519
let txn_req = TxnRequest::new(condition.clone(), if_then.clone());
520520

521521
let tx_reply = self.kv_api.transaction(txn_req.clone()).await?;
522-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
522+
let (succ, _) = unpack_txn_reply(tx_reply);
523523

524524
if succ {
525525
return Ok(());

src/query/management/src/stage/stage_mgr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use databend_common_exception::ErrorCode;
1818
use databend_common_exception::Result;
1919
use databend_common_meta_api::kv_pb_api::KVPbApi;
2020
use databend_common_meta_api::kv_pb_api::UpsertPB;
21-
use databend_common_meta_api::reply::txn_reply_to_api_result;
21+
use databend_common_meta_api::reply::unpack_txn_reply;
2222
use databend_common_meta_api::txn_cond_eq_seq;
2323
use databend_common_meta_api::txn_cond_seq;
2424
use databend_common_meta_api::txn_op_del;
@@ -152,7 +152,7 @@ impl StageApi for StageMgr {
152152
dels,
153153
);
154154
let tx_reply = self.kv_api.transaction(txn_req).await?;
155-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
155+
let (succ, _) = unpack_txn_reply(tx_reply);
156156

157157
if succ {
158158
return Ok(());
@@ -214,7 +214,7 @@ impl StageApi for StageMgr {
214214
);
215215

216216
let tx_reply = self.kv_api.transaction(txn_req).await?;
217-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
217+
let (succ, _) = unpack_txn_reply(tx_reply);
218218

219219
if succ {
220220
return Ok(0);
@@ -275,7 +275,7 @@ impl StageApi for StageMgr {
275275
if_then,
276276
);
277277
let tx_reply = self.kv_api.transaction(txn_req).await?;
278-
let (succ, _) = txn_reply_to_api_result(tx_reply)?;
278+
let (succ, _) = unpack_txn_reply(tx_reply);
279279

280280
if succ {
281281
return Ok(());

0 commit comments

Comments
 (0)