glusterd: Fetching the txn_id before performing glusterd_op_bricks_select in glusterd_brick_op()
In glusterd_brick_op(), the txn_id mut be fetched before failing the transaction for any other reason. Moving the fetching of txn_id to the beginning of the function. Also initializing txn_id to priv->global_txn_id where it wasn't initialized. Change-Id: I44d7daa444f00a626f24670c92324725f6c5fb35 BUG: 1102656 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/7926 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
This commit is contained in:
parent
4f9314a5ed
commit
e8c13fa9bd
20
tests/bugs/bug-1102656.t
Normal file
20
tests/bugs/bug-1102656.t
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../include.rc
|
||||
|
||||
cleanup;
|
||||
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
TEST $CLI volume create $V0 replica 2 $H0:$B0/brick0 $H0:$B0/brick1
|
||||
TEST $CLI volume start $V0
|
||||
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume top $V0 open
|
||||
TEST ! $CLI volume top $V0 open brick $H0:/tmp/brick
|
||||
TEST $CLI volume top $V0 read
|
||||
|
||||
TEST $CLI volume status
|
||||
TEST $CLI volume stop $V0
|
||||
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Stopped' volinfo_field $V0 'Status';
|
||||
cleanup;
|
@ -905,6 +905,18 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = glusterd_req_ctx_create (req, op_req.op, op_req.uuid,
|
||||
op_req.buf.buf_val, op_req.buf.buf_len,
|
||||
gf_gld_mt_op_stage_ctx_t, &req_ctx);
|
||||
if (ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Failed to create req_ctx");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) {
|
||||
gf_log (this->name, GF_LOG_WARNING, "%s doesn't "
|
||||
"belong to the cluster. Ignoring request.",
|
||||
@ -913,16 +925,6 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = glusterd_req_ctx_create (req, op_req.op, op_req.uuid,
|
||||
op_req.buf.buf_val, op_req.buf.buf_len,
|
||||
gf_gld_mt_op_stage_ctx_t, &req_ctx);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
|
||||
/* In cases where there is no volname, the receivers won't have a
|
||||
* transaction opinfo created, as for those operations, the locking
|
||||
* phase where the transaction opinfos are created, won't be called. */
|
||||
@ -1009,8 +1011,8 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req)
|
||||
goto out;
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_OP,
|
||||
txn_id, req_ctx);
|
||||
|
@ -6488,7 +6488,7 @@ glusterd_op_sm ()
|
||||
"type: '%s'",
|
||||
glusterd_op_sm_event_name_get(event_type));
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s",
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (event->txn_id));
|
||||
|
||||
ret = glusterd_get_txn_opinfo (&event->txn_id,
|
||||
|
@ -1929,6 +1929,7 @@ glusterd_do_replace_brick (void *data)
|
||||
int32_t op = 0;
|
||||
int32_t src_port = 0;
|
||||
int32_t dst_port = 0;
|
||||
int32_t ret = 0;
|
||||
dict_t *dict = NULL;
|
||||
char *src_brick = NULL;
|
||||
char *dst_brick = NULL;
|
||||
@ -1937,16 +1938,16 @@ glusterd_do_replace_brick (void *data)
|
||||
glusterd_brickinfo_t *dst_brickinfo = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
uuid_t *txn_id = NULL;
|
||||
xlator_t *this = NULL;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
dict = data;
|
||||
|
||||
GF_ASSERT (THIS);
|
||||
priv = THIS->private;
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
GF_ASSERT (data);
|
||||
|
||||
txn_id = &priv->global_txn_id;
|
||||
dict = data;
|
||||
|
||||
if (priv->timer) {
|
||||
gf_timer_call_cancel (THIS->ctx, priv->timer);
|
||||
@ -1959,8 +1960,8 @@ glusterd_do_replace_brick (void *data)
|
||||
"Replace brick operation detected");
|
||||
|
||||
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
ret = dict_get_int32 (dict, "operation", &op);
|
||||
if (ret) {
|
||||
|
@ -897,11 +897,16 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
char err_str[2048] = {0};
|
||||
char *peer_str = NULL;
|
||||
xlator_t *this = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
uuid_t *txn_id = NULL;
|
||||
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
GF_ASSERT (req);
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
txn_id = &priv->global_txn_id;
|
||||
|
||||
if (-1 == req->rpc_status) {
|
||||
rsp.op_ret = -1;
|
||||
@ -951,17 +956,14 @@ out:
|
||||
(op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid));
|
||||
|
||||
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
|
||||
|
||||
if (ret) {
|
||||
if (ret)
|
||||
gf_log (this->name, GF_LOG_CRITICAL, "Stage response received "
|
||||
"from unknown peer: %s. Ignoring response.",
|
||||
uuid_utoa (rsp.uuid));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (op_ret) {
|
||||
event_type = GD_OP_EVENT_RCVD_RJT;
|
||||
@ -977,10 +979,8 @@ out:
|
||||
OPERRSTR_STAGE_FAIL, peer_str);
|
||||
opinfo.op_errstr = gf_strdup (err_str);
|
||||
}
|
||||
if (!opinfo.op_errstr) {
|
||||
if (!opinfo.op_errstr)
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
event_type = GD_OP_EVENT_RCVD_ACC;
|
||||
}
|
||||
@ -1031,12 +1031,16 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
char err_str[2048] = {0};
|
||||
char *peer_str = NULL;
|
||||
xlator_t *this = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
uuid_t *txn_id = NULL;
|
||||
|
||||
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
GF_ASSERT (req);
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
txn_id = &priv->global_txn_id;
|
||||
|
||||
if (-1 == req->rpc_status) {
|
||||
rsp.op_ret = -1;
|
||||
@ -1087,11 +1091,10 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
(op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid));
|
||||
|
||||
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
|
||||
|
||||
if (ret) {
|
||||
gf_log (this->name, GF_LOG_CRITICAL, "Commit response for "
|
||||
"'Volume %s' received from unknown peer: %s",
|
||||
@ -1791,9 +1794,12 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
}
|
||||
out:
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
if (req_ctx && req_ctx->dict) {
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id",
|
||||
(void **)&txn_id);
|
||||
gf_log (this->name, GF_LOG_DEBUG,
|
||||
"transaction ID = %s", uuid_utoa (*txn_id));
|
||||
}
|
||||
|
||||
ev_ctx = GF_CALLOC (1, sizeof (*ev_ctx), gf_gld_mt_brick_rsp_ctx_t);
|
||||
GF_ASSERT (ev_ctx);
|
||||
@ -1857,6 +1863,11 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this,
|
||||
req_ctx = data;
|
||||
GF_ASSERT (req_ctx);
|
||||
INIT_LIST_HEAD (&opinfo.pending_bricks);
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
|
||||
uuid_utoa (*txn_id));
|
||||
|
||||
ret = glusterd_op_bricks_select (req_ctx->op, req_ctx->dict, &op_errstr,
|
||||
&opinfo.pending_bricks, NULL);
|
||||
|
||||
@ -1868,11 +1879,6 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this,
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
|
||||
|
||||
gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
|
||||
|
||||
list_for_each_entry (pending_node, &opinfo.pending_bricks, list) {
|
||||
dummy_frame = create_frame (this, this->ctx->pool);
|
||||
if (!dummy_frame)
|
||||
|
Loading…
x
Reference in New Issue
Block a user