Skip to content

Commit

Permalink
Merge pull request #6591 from chu11/kvs_cleanups
Browse files Browse the repository at this point in the history
kvs: misc minor cleanups
  • Loading branch information
mergify[bot] authored Jan 31, 2025
2 parents fb2f0ac + bf45b00 commit 88092cd
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 27 deletions.
1 change: 1 addition & 0 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ MAN3_FILES_SECONDARY = \
man3/flux_kvs_getroot_cancel.3 \
man3/flux_kvs_fence.3 \
man3/flux_kvs_commit_get_treeobj.3 \
man3/flux_kvs_commit_get_rootref.3 \
man3/flux_kvs_commit_get_sequence.3 \
man3/flux_kvs_txn_destroy.3 \
man3/flux_kvs_txn_put.3 \
Expand Down
24 changes: 15 additions & 9 deletions doc/man3/flux_kvs_commit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ SYNOPSIS
int flux_kvs_commit_get_treeobj (flux_future_t *f,
const char **treeobj);
int flux_kvs_commit_get_rootref (flux_future_t *f,
const char **rootref);
int flux_kvs_commit_get_sequence (flux_future_t *f, int *seq);
Link with :command:`-lflux-core`.
Expand Down Expand Up @@ -57,22 +60,25 @@ complete.
request has been received. :man3:`flux_future_wait_for` may be used to
block until the response has been received. Both accept an optional timeout.

:man3:`flux_future_get`, :func:`flux_kvs_commit_get_treeobj`, or
:func:`flux_kvs_commit_get_sequence` can decode the response. A return of
0 indicates success and the entire transaction was committed. A
return of -1 indicates failure, none of the transaction was committed.
All can be used on the :type:`flux_future_t` returned by :func:`flux_kvs_commit`
or :func:`flux_kvs_fence`.
:man3:`flux_future_get`, :func:`flux_kvs_commit_get_treeobj`,
:func:`flux_kvs_commit_get_rootref`, or :func:`flux_kvs_commit_get_sequence`
can decode the response. A return of 0 indicates success and the
entire transaction was committed. A return of -1 indicates failure,
none of the transaction was committed. All can be used on the
:type:`flux_future_t` returned by :func:`flux_kvs_commit` or
:func:`flux_kvs_fence`.

In addition to checking for success or failure,
:func:`flux_kvs_commit_get_treeobj` and :func:`flux_kvs_commit_get_sequence`
can return information about the root snapshot that the commit or
fence has completed its transaction on.
:func:`flux_kvs_commit_get_treeobj`, :func:`flux_kvs_commit_get_rootref()`,
and :func:`flux_kvs_commit_get_sequence` can return information about the
root snapshot that the commit or fence has completed its transaction on.

:func:`flux_kvs_commit_get_treeobj` obtains the root hash in the form of
an RFC 11 *dirref* treeobj, suitable to be passed to
:man3:`flux_kvs_lookupat`.

:func:`flux_kvs_commit_get_rootref` retrieves the blobref for the root.

:func:`flux_kvs_commit_get_sequence` retrieves the monotonic sequence number
for the root.

Expand Down
1 change: 1 addition & 0 deletions doc/manpages.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
('man3/flux_idle_watcher_create', 'flux_idle_watcher_create', 'create prepare/check/idle watchers', [author], 3),
('man3/flux_kvs_commit', 'flux_kvs_fence', 'commit a KVS transaction', [author], 3),
('man3/flux_kvs_commit', 'flux_kvs_commit_get_treeobj', 'commit a KVS transaction', [author], 3),
('man3/flux_kvs_commit', 'flux_kvs_commit_get_rootref', 'commit a KVS transaction', [author], 3),
('man3/flux_kvs_commit', 'flux_kvs_commit_get_sequence', 'commit a KVS transaction', [author], 3),
('man3/flux_kvs_commit', 'flux_kvs_commit', 'commit a KVS transaction', [author], 3),
('man3/flux_kvs_copy', 'flux_kvs_move', 'copy/move a KVS key', [author], 3),
Expand Down
1 change: 0 additions & 1 deletion src/broker/broker.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct broker {
zlist_t *sigwatchers;
struct service_switch *services;
struct brokercfg *config;
double heartbeat_rate;
struct subhash *sub; /* subscriptions for internal services */
struct content_cache *cache;
struct publisher *publisher;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ static void commit_request_cb (flux_t *h,
* the ready queue. We don't need to call
* treq_count_reached() b/c this is a commit and nprocs is 1
*/
treq_set_processed (tr, true);
treq_mark_processed (tr);

if (kvstxn_mgr_add_transaction (root->ktm,
treq_get_name (tr),
Expand Down Expand Up @@ -1915,7 +1915,7 @@ static void relayfence_request_cb (flux_t *h,

/* we use this flag to indicate if a treq has been added to
* the ready queue */
treq_set_processed (tr, true);
treq_mark_processed (tr);

if (kvstxn_mgr_add_transaction (root->ktm,
treq_get_name (tr),
Expand Down Expand Up @@ -2036,7 +2036,7 @@ static void fence_request_cb (flux_t *h,

/* we use this flag to indicate if a treq has been added to
* the ready queue */
treq_set_processed (tr, true);
treq_mark_processed (tr);

if (kvstxn_mgr_add_transaction (root->ktm,
treq_get_name (tr),
Expand Down
25 changes: 20 additions & 5 deletions src/modules/kvs/test/kvstxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void kvstxn_mgr_merge_tests (void)
ops,
FLUX_KVS_NO_MERGE,
0,
"unmerged transaction");
"unmerged transaction (no merge 1)");

json_decref (names);
json_decref (ops);
Expand All @@ -539,7 +539,12 @@ void kvstxn_mgr_merge_tests (void)
ops = json_array ();
ops_append (ops, "key1", "1", 0);

verify_ready_kvstxn (ktm, names, ops, 0, 0, "unmerged transaction");
verify_ready_kvstxn (ktm,
names,
ops,
0,
0,
"unmerged transaction (no merge 2)");

json_decref (names);
json_decref (ops);
Expand All @@ -566,7 +571,7 @@ void kvstxn_mgr_merge_tests (void)
ops,
FLUX_KVS_SYNC,
0,
"unmerged transaction");
"unmerged transaction (sync 1)");

json_decref (names);
json_decref (ops);
Expand All @@ -588,7 +593,12 @@ void kvstxn_mgr_merge_tests (void)
ops = json_array ();
ops_append (ops, "key1", "1", 0);

verify_ready_kvstxn (ktm, names, ops, 0, 0, "unmerged transaction");
verify_ready_kvstxn (ktm,
names,
ops,
0,
0,
"unmerged transaction (sync 2)");

json_decref (names);
json_decref (ops);
Expand All @@ -610,7 +620,12 @@ void kvstxn_mgr_merge_tests (void)
ops = json_array ();
ops_append (ops, "key1", "1", 0);

verify_ready_kvstxn (ktm, names, ops, 0, 0, "unmerged fence");
verify_ready_kvstxn (ktm,
names,
ops,
0,
0,
"unmerged transaction (diff flags)");

json_decref (names);
json_decref (ops);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kvs/test/treq.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void treq_basic_tests (void)
ok (treq_get_processed (tr) == false,
"treq_get_processed returns false initially");

treq_set_processed (tr, true);
treq_mark_processed (tr);

ok (treq_get_processed (tr) == true,
"treq_get_processed returns true");
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kvs/treq.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ bool treq_get_processed (treq_t *tr)
return tr->processed;
}

void treq_set_processed (treq_t *tr, bool p)
void treq_mark_processed (treq_t *tr)
{
tr->processed = p;
tr->processed = true;
}

/*
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 @@ -91,7 +91,7 @@ int treq_iter_request_copies (treq_t *tr, treq_msg_cb cb, void *data);
/* convenience processing flag
*/
bool treq_get_processed (treq_t *tr);
void treq_set_processed (treq_t *tr, bool p);
void treq_mark_processed (treq_t *tr);

#endif /* !_FLUX_KVS_TREQ_H */

Expand Down
17 changes: 12 additions & 5 deletions t/kvs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/asyncfence
/basic
/blobref
/commit
/commit_order
/content-spam
/dtree
/getas
/hashtest
/fence_api
/fence_invalid
/fence_namespace_remove
/issue1760
/issue1876
/lookup_invalid
/setrootevents
/torture
/watch
/transactionmerge
/waitcreate_cancel
/watch_disconnect
/watch_stream

0 comments on commit 88092cd

Please sign in to comment.