Skip to content

Commit

Permalink
modules/kvs: Use rank & seq for commit txn name
Browse files Browse the repository at this point in the history
For commit transactions, instead of generating a name using
an expensive to generate uuid, instead use a simple fixed
name involving a flux rank and a per rank sequence number.

Fixes #1446
  • Loading branch information
chu11 committed Apr 12, 2018
1 parent c0a9876 commit 9a58b97
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct {
int transaction_merge;
bool events_init; /* flag */
const char *hash_name;
unsigned int seq; /* for commit transactions */
} kvs_ctx_t;

struct kvs_cb_data {
Expand Down Expand Up @@ -1818,8 +1819,6 @@ static void commit_request_cb (flux_t *h, flux_msg_handler_t *mh,
kvs_ctx_t *ctx = arg;
struct kvsroot *root;
const char *namespace;
zuuid_t *uuid = NULL;
const char *name;
int saved_errno, flags;
bool stall = false;
json_t *ops = NULL;
Expand Down Expand Up @@ -1847,14 +1846,8 @@ static void commit_request_cb (flux_t *h, flux_msg_handler_t *mh,
goto error;
}

if (!(uuid = zuuid_new ())) {
flux_log_error (h, "%s: zuuid_new", __FUNCTION__);
goto error;
}
name = zuuid_str (uuid);

if (!(tr = treq_create (name, 1, flags))) {
flux_log_error (h, "%s: treq_create", __FUNCTION__);
if (!(tr = treq_create_rank (ctx->rank, ctx->seq++, 1, flags))) {
flux_log_error (h, "%s: treq_create_rank", __FUNCTION__);
goto error;
}
if (treq_mgr_add_transaction (root->trm, tr) < 0) {
Expand All @@ -1880,7 +1873,7 @@ static void commit_request_cb (flux_t *h, flux_msg_handler_t *mh,
treq_set_processed (tr, true);

if (kvstxn_mgr_add_transaction (root->ktm,
name,
treq_get_name (tr),
ops,
flags) < 0) {
flux_log_error (h, "%s: kvstxn_mgr_add_transaction",
Expand All @@ -1895,7 +1888,7 @@ static void commit_request_cb (flux_t *h, flux_msg_handler_t *mh,
if (!(f = flux_rpc_pack (h, "kvs.relaycommit", 0, FLUX_RPC_NORESPONSE,
"{ s:O s:s s:s s:i }",
"ops", ops,
"name", name,
"name", treq_get_name (tr),
"namespace", alt_ns ? alt_ns : namespace,
"flags", flags))) {
flux_log_error (h, "%s: flux_rpc_pack", __FUNCTION__);
Expand All @@ -1909,7 +1902,6 @@ static void commit_request_cb (flux_t *h, flux_msg_handler_t *mh,
if (flux_respond (h, msg, errno, NULL) < 0)
flux_log_error (h, "%s: flux_respond", __FUNCTION__);
stall:
zuuid_destroy (&uuid);
free (alt_ns);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kvs/treq.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ treq_t *treq_create (const char *name, int nprocs, int flags)
return NULL;
}

treq_t *treq_create_rank (uint32_t rank, uint32_t seq, int nprocs, int flags)
treq_t *treq_create_rank (uint32_t rank, unsigned int seq, int nprocs, int flags)
{
treq_t *tr = NULL;
int saved_errno;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kvs/treq.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int treq_mgr_transactions_count (treq_mgr_t *trm);
treq_t *treq_create (const char *name, int nprocs, int flags);

/* treq_create_rank - internally will create name based on rank & seq */
treq_t *treq_create_rank (uint32_t rank, uint32_t seq, int nprocs, int flags);
treq_t *treq_create_rank (uint32_t rank, unsigned int seq, int nprocs, int flags);

void treq_destroy (treq_t *tr);

Expand Down

0 comments on commit 9a58b97

Please sign in to comment.