From 93ca24cd1e3f32612d17b9e5017b9e40a5a1ec59 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Fri, 24 Jan 2025 11:06:15 -0800 Subject: [PATCH 1/3] libkvs: fix comment typo Problem: There is an errant typo in which an upper case example is written lower case. Make the example character upper case. --- src/common/libkvs/kvs_txn_compact.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/libkvs/kvs_txn_compact.c b/src/common/libkvs/kvs_txn_compact.c index 827e67a88bf4..a0494765697c 100644 --- a/src/common/libkvs/kvs_txn_compact.c +++ b/src/common/libkvs/kvs_txn_compact.c @@ -42,7 +42,7 @@ * * append "A" * write "B" - * append "c" + * append "C" * * we cannot combine the appends of "A" and "C". In this scenario, we * generate an EINVAL error to the caller, indicating that the From c7728d5edfadbc8263765e0f5e1821a840789a18 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Fri, 24 Jan 2025 11:31:03 -0800 Subject: [PATCH 2/3] t/kvs: improve fence_api usage / variable names Problem: The very generic word "count" is used in the tool's usage and variable names. Update to "fence count" to make this more clear. --- t/kvs/fence_api.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/kvs/fence_api.c b/t/kvs/fence_api.c index 79615bb285fe..4f30b78af4d5 100644 --- a/t/kvs/fence_api.c +++ b/t/kvs/fence_api.c @@ -38,7 +38,7 @@ typedef struct { int sequence; } thd_t; -static int count = -1; +static int fencecount = -1; static char *prefix = NULL; static char *fence_name; static bool syncflag = false; @@ -58,7 +58,7 @@ static void usage (void) fprintf (stderr, "Usage: fence_api " "[--sync] [--symlink] [--namespace=ns] " - "count prefix\n"); + " \n"); exit (1); } @@ -104,7 +104,7 @@ void *thread (void *arg) flags |= FLUX_KVS_SYNC; if (!(f = flux_kvs_fence (t->h, namespace, flags, fence_name, - count, txn)) + fencecount, txn)) || flux_future_get (f, NULL) < 0) log_err_exit ("flux_kvs_fence"); @@ -157,9 +157,9 @@ int main (int argc, char *argv[]) if ((argc - optind) != 2) usage (); - count = strtoul (argv[optind], NULL, 10); - if (count <= 1) - log_msg_exit ("commit count must be > 1"); + fencecount = strtoul (argv[optind], NULL, 10); + if (fencecount <= 1) + log_msg_exit ("thread count must be > 1"); prefix = argv[optind+1]; /* create a fence name for this test that is random-ish */ @@ -167,9 +167,9 @@ int main (int argc, char *argv[]) num = rand (); fence_name = xasprintf ("%s-%d", prefix, num); - thd = xzmalloc (sizeof (*thd) * count); + thd = xzmalloc (sizeof (*thd) * fencecount); - for (i = 0; i < count; i++) { + for (i = 0; i < fencecount; i++) { thd[i].n = i; if ((rc = pthread_attr_init (&thd[i].attr))) log_errn (rc, "pthread_attr_init"); @@ -177,7 +177,7 @@ int main (int argc, char *argv[]) log_errn (rc, "pthread_create"); } - for (i = 0; i < count; i++) { + for (i = 0; i < fencecount; i++) { if ((rc = pthread_join (thd[i].t, NULL))) log_errn (rc, "pthread_join"); } @@ -185,7 +185,7 @@ int main (int argc, char *argv[]) /* compare results from all of the fences, the root ref info * should all be the same */ - for (i = 1; i < count; i++) { + for (i = 1; i < fencecount; i++) { if (!streq (thd[0].treeobj, thd[i].treeobj)) log_msg_exit ("treeobj mismatch: %s != %s\n", thd[0].treeobj, thd[i].treeobj); @@ -197,7 +197,7 @@ int main (int argc, char *argv[]) thd[0].sequence, thd[i].sequence); } - for (i = 0; i < count; i++) { + for (i = 0; i < fencecount; i++) { free (thd[i].treeobj); free (thd[i].rootref); } From 7bce3b849e40a0323ca79f9a0b01dbcfc2f0b6e9 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Thu, 23 Jan 2025 15:38:53 -0800 Subject: [PATCH 3/3] kvs: report error to all fence requests Problem: When an error occurs in a fence request, the error is only reported to the requestor. In most cases, this is fine, but the error should be reported to all members of the fence in some cases. Most notably, it should be reported to all members of the fence when the fence count has been reached and an error has occurred after this point. Solution: In fence_request_cb() return an error via the kvs function error_event_send_to_name() when it is appropriate. --- src/modules/kvs/kvs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/kvs/kvs.c b/src/modules/kvs/kvs.c index 4cd5043d6552..426a6ee60230 100644 --- a/src/modules/kvs/kvs.c +++ b/src/modules/kvs/kvs.c @@ -2046,7 +2046,7 @@ static void fence_request_cb (flux_t *h, flux_log_error (h, "%s: kvstxn_mgr_add_transaction", __FUNCTION__); - goto error; + goto error_all; } tstat_push (&ctx->txn_fence_stats, @@ -2077,6 +2077,16 @@ static void fence_request_cb (flux_t *h, request_tracking_add (ctx, msg); return; +error_all: + /* An error has occurred, so we will return an error similarly to + * how an error would be returned via a transaction error in + * kvstxn_apply(). + */ + if (error_event_send_to_name (ctx, ns, name, errno) < 0) + flux_log_error (h, "%s: error_event_send_to_name", __FUNCTION__); + request_tracking_remove (ctx, msg); + return; + error: if (flux_respond_error (h, msg, errno, errmsg) < 0) flux_log_error (h, "%s: flux_respond_error", __FUNCTION__);