Skip to content

Commit be350d6

Browse files
authored
Merge pull request #6622 from chu11/issue6608_kvs_dropcache_remove
kvs: remove dropcache
2 parents fc1413b + 4b52519 commit be350d6

File tree

11 files changed

+37
-200
lines changed

11 files changed

+37
-200
lines changed

doc/man1/flux-kvs.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ SYNOPSIS
1414
| **flux** **kvs** **link** *target* *linkname*
1515
| **flux** **kvs** **readlink** *key...*
1616
| **flux** **kvs** **mkdir** *key...*
17-
| **flux** **kvs** **dropcache**
1817
1918
| **flux** **kvs** **copy** *source* *destination*
2019
| **flux** **kvs** **move** *source* *destination*
@@ -361,18 +360,6 @@ Create an empty directory. If *key* exists, it is overwritten.
361360
After the commit has completed, display the new root sequence number
362361
or "version".
363362

364-
dropcache
365-
---------
366-
367-
.. program:: flux kvs dropcache
368-
369-
Tell the local KVS to drop any cache it is holding.
370-
371-
.. option:: -a, --all
372-
373-
Publish an event across the Flux instance instructing the KVS module on
374-
all ranks to drop their caches.
375-
376363
copy
377364
----
378365

etc/completions/flux.pre

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,6 @@ _flux_kvs()
10271027
mkdir
10281028
copy
10291029
move
1030-
dropcache
10311030
version
10321031
wait
10331032
getroot
@@ -1106,9 +1105,6 @@ _flux_kvs()
11061105
move_OPTS="\
11071106
${copy_OPTS}
11081107
"
1109-
dropcache_OPTS="\
1110-
-a --all
1111-
"
11121108
version_OPTS="\
11131109
-N --namespace= \
11141110
"

src/bindings/python/flux/kvs.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,6 @@ def namespace_list(flux_handle):
366366
return nslist
367367

368368

369-
def dropcache(flux_handle):
370-
"""Drop KVS cache entries
371-
372-
Inform KVS module to drop cache entries without a reference.
373-
374-
Args:
375-
flux_handle: A Flux handle obtained from flux.Flux()
376-
"""
377-
RAW.flux_kvs_dropcache(flux_handle)
378-
379-
380369
class KVSTxn:
381370
"""KVS Transaction Object
382371

src/cmd/flux-kvs.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ int cmd_readlink (optparse_t *p, int argc, char **argv);
4242
int cmd_mkdir (optparse_t *p, int argc, char **argv);
4343
int cmd_version (optparse_t *p, int argc, char **argv);
4444
int cmd_wait (optparse_t *p, int argc, char **argv);
45-
int cmd_dropcache (optparse_t *p, int argc, char **argv);
4645
int cmd_copy (optparse_t *p, int argc, char **argv);
4746
int cmd_move (optparse_t *p, int argc, char **argv);
4847
int cmd_dir (optparse_t *p, int argc, char **argv);
@@ -184,13 +183,6 @@ static struct optparse_option ls_opts[] = {
184183
OPTPARSE_TABLE_END
185184
};
186185

187-
static struct optparse_option dropcache_opts[] = {
188-
{ .name = "all", .key = 'a', .has_arg = 0,
189-
.usage = "Drop KVS across all ranks",
190-
},
191-
OPTPARSE_TABLE_END
192-
};
193-
194186
static struct optparse_option unlink_opts[] = {
195187
{ .name = "namespace", .key = 'N', .has_arg = 1,
196188
.usage = "Specify KVS namespace to use.",
@@ -360,13 +352,6 @@ static struct optparse_subcommand subcommands[] = {
360352
0,
361353
copy_opts
362354
},
363-
{ "dropcache",
364-
"[--all]",
365-
"Tell KVS to drop its cache",
366-
cmd_dropcache,
367-
0,
368-
dropcache_opts
369-
},
370355
{ "version",
371356
"[-N ns]",
372357
"Display current KVS version",
@@ -1213,27 +1198,6 @@ int cmd_wait (optparse_t *p, int argc, char **argv)
12131198
return (0);
12141199
}
12151200

1216-
int cmd_dropcache (optparse_t *p, int argc, char **argv)
1217-
{
1218-
flux_t *h;
1219-
1220-
if (!(h = flux_open (NULL, 0)))
1221-
log_err_exit ("flux_open");
1222-
1223-
if (optparse_hasopt (p, "all")) {
1224-
flux_msg_t *msg = flux_event_encode ("kvs.dropcache", NULL);
1225-
if (!msg || flux_send (h, msg, 0) < 0)
1226-
log_err_exit ("flux_send");
1227-
flux_msg_destroy (msg);
1228-
}
1229-
else {
1230-
if (flux_kvs_dropcache (h) < 0)
1231-
log_err_exit ("flux_kvs_dropcache");
1232-
}
1233-
flux_close (h);
1234-
return (0);
1235-
}
1236-
12371201
static char *process_key (const char *key)
12381202
{
12391203
char *nkey;

src/common/libkvs/kvs.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,6 @@ int flux_kvs_wait_version (flux_t *h, const char *ns, int version)
162162
return ret;
163163
}
164164

165-
int flux_kvs_dropcache (flux_t *h)
166-
{
167-
flux_future_t *f;
168-
int rc = -1;
169-
170-
if (!(f = flux_rpc (h, "kvs.dropcache", NULL, FLUX_NODEID_ANY, 0)))
171-
goto done;
172-
if (flux_future_get (f, NULL) < 0)
173-
goto done;
174-
rc = 0;
175-
done:
176-
flux_future_destroy (f);
177-
return rc;
178-
}
179-
180165
/*
181166
* vi:tabstop=4 shiftwidth=4 expandtab
182167
*/

src/common/libkvs/kvs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ flux_future_t *flux_kvs_namespace_remove (flux_t *h, const char *ns);
6666
int flux_kvs_get_version (flux_t *h, const char *ns, int *versionp);
6767
int flux_kvs_wait_version (flux_t *h, const char *ns, int version);
6868

69-
/* Garbage collect the cache. Drop all data that doesn't have a
70-
* reference in the namespace.
71-
* Returns -1 on error (errno set), 0 on success.
72-
*/
73-
int flux_kvs_dropcache (flux_t *h);
74-
7569
#ifdef __cplusplus
7670
}
7771
#endif

src/modules/kvs/kvs.c

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,6 @@ static int event_subscribe (struct kvs_ctx *ctx, const char *ns)
222222
*/
223223

224224
if (!(ctx->events_init)) {
225-
226-
/* These belong to all namespaces, subscribe once the first
227-
* time we init a namespace */
228-
229-
if (flux_event_subscribe (ctx->h, "kvs.dropcache") < 0) {
230-
flux_log_error (ctx->h, "flux_event_subscribe");
231-
goto cleanup;
232-
}
233-
234225
/* On rank 0, we need to listen for all of these namespace
235226
* events, all of the time. So subscribe to them just once on
236227
* rank 0. */
@@ -1171,62 +1162,6 @@ static void transaction_check_cb (flux_reactor_t *r,
11711162
* rpc/event callbacks
11721163
*/
11731164

1174-
static void dropcache_request_cb (flux_t *h, flux_msg_handler_t *mh,
1175-
const flux_msg_t *msg, void *arg)
1176-
{
1177-
struct kvs_ctx *ctx = arg;
1178-
int size, expcount = 0;
1179-
1180-
/* irrelevant if root not initialized, drop cache entries */
1181-
1182-
if (flux_request_decode (msg, NULL, NULL) < 0)
1183-
goto error;
1184-
size = cache_count_entries (ctx->cache);
1185-
if ((expcount = cache_expire_entries (ctx->cache, 0)) < 0) {
1186-
flux_log_error (ctx->h, "%s: cache_expire_entries", __FUNCTION__);
1187-
goto error;
1188-
}
1189-
else {
1190-
flux_log (h,
1191-
LOG_ALERT,
1192-
"dropped %d of %d cache entries",
1193-
expcount,
1194-
size);
1195-
}
1196-
if (flux_respond (h, msg, NULL) < 0)
1197-
flux_log_error (h, "%s: flux_respond", __FUNCTION__);
1198-
return;
1199-
error:
1200-
if (flux_respond_error (h, msg, errno, NULL) < 0)
1201-
flux_log_error (h, "%s: flux_respond_error", __FUNCTION__);
1202-
}
1203-
1204-
static void dropcache_event_cb (flux_t *h,
1205-
flux_msg_handler_t *mh,
1206-
const flux_msg_t *msg,
1207-
void *arg)
1208-
{
1209-
struct kvs_ctx *ctx = arg;
1210-
int size, expcount = 0;
1211-
1212-
/* irrelevant if root not initialized, drop cache entries */
1213-
1214-
if (flux_event_decode (msg, NULL, NULL) < 0) {
1215-
flux_log_error (ctx->h, "%s: flux_event_decode", __FUNCTION__);
1216-
return;
1217-
}
1218-
size = cache_count_entries (ctx->cache);
1219-
if ((expcount = cache_expire_entries (ctx->cache, 0)) < 0)
1220-
flux_log_error (ctx->h, "%s: cache_expire_entries", __FUNCTION__);
1221-
else {
1222-
flux_log (h,
1223-
LOG_ALERT,
1224-
"dropped %d of %d cache entries",
1225-
expcount,
1226-
size);
1227-
}
1228-
}
1229-
12301165
static int heartbeat_root_cb (struct kvsroot *root, void *arg)
12311166
{
12321167
struct kvs_ctx *ctx = arg;
@@ -2600,18 +2535,6 @@ static const struct flux_msg_handler_spec htab[] = {
26002535
getroot_request_cb,
26012536
FLUX_ROLE_USER
26022537
},
2603-
{
2604-
FLUX_MSGTYPE_REQUEST,
2605-
"kvs.dropcache",
2606-
dropcache_request_cb,
2607-
0
2608-
},
2609-
{
2610-
FLUX_MSGTYPE_EVENT,
2611-
"kvs.dropcache",
2612-
dropcache_event_cb,
2613-
0
2614-
},
26152538
{
26162539
FLUX_MSGTYPE_REQUEST,
26172540
"kvs.disconnect",
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
#!/bin/sh -e
22
# dropcache, do a put that misses a references, unlink a dir, the reference
33
# should not be missing.
4+
#
5+
# N.B. the reason this test is split across two flux starts is we need the
6+
# internal KVS cache to be empty
47

5-
TEST=issue1760
6-
${FLUX_BUILD_DIR}/t/kvs/issue1760 a
8+
cat <<-EOF >t1760setup.sh
9+
#!/bin/sh -e
10+
11+
flux kvs mkdir foo
12+
13+
EOF
14+
15+
cat <<-EOF >t1760test.sh
16+
#!/bin/sh -e
17+
18+
${FLUX_BUILD_DIR}/t/kvs/issue1760 foo
19+
20+
EOF
21+
22+
chmod +x t1760setup.sh
23+
chmod +x t1760test.sh
24+
25+
STATEDIR=issue1760-statedir
26+
mkdir issue1760-statedir
27+
28+
flux start -s 1 \
29+
--setattr=statedir=${STATEDIR} \
30+
./t1760setup.sh
31+
32+
flux start -s 1 \
33+
--setattr=statedir=${STATEDIR} \
34+
./t1760test.sh

t/kvs/issue1760.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* SPDX-License-Identifier: LGPL-3.0
99
\************************************************************/
1010

11-
/* issue1760.c - make kvs module sad */
11+
/* issue1760.c - make kvs module sad
12+
*
13+
* - it is assumed the directory passed in under argv[1] has already
14+
* been created. The command line `flux kvs` command does not allow
15+
* a put & unlink to be done under a single transaction, thus the need
16+
* for this utility test.
17+
*/
1218

1319
/* Failure mode 1:
1420
./issue1760 a
@@ -52,24 +58,6 @@ int main (int argc, char *argv[])
5258
if (!(h = flux_open (NULL, 0)))
5359
log_err_exit ("flux_open");
5460

55-
/* Mkdir <dir>
56-
*/
57-
if (!(txn = flux_kvs_txn_create ()))
58-
log_err_exit ("flux_kvs_txn_create");
59-
if (flux_kvs_txn_mkdir (txn, 0, dir) < 0)
60-
log_err_exit ("flux_kvs_txn_mkdir");
61-
if (!(f = flux_kvs_commit (h, NULL, 0, txn)))
62-
log_err_exit ("flux_kvs_commit");
63-
if (flux_future_get (f, NULL) < 0)
64-
log_err_exit ("flux_future_get");
65-
flux_future_destroy (f);
66-
flux_kvs_txn_destroy (txn);
67-
68-
/* Expire internal kvs cache
69-
*/
70-
if (flux_kvs_dropcache (h) < 0)
71-
log_err_exit ("flux_kvs_dropcache");
72-
7361
/* Commit the following:
7462
* put <dir>.a
7563
* unlink <dir>

t/t1000-kvs.t

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,17 +1164,6 @@ test_expect_success 'kvs: --sequence on write ops works' '
11641164
test $VER -eq $SEQ
11651165
'
11661166

1167-
#
1168-
# dropcache tests
1169-
#
1170-
1171-
test_expect_success 'kvs: dropcache works' '
1172-
flux kvs dropcache
1173-
'
1174-
test_expect_success 'kvs: dropcache --all works' '
1175-
flux kvs dropcache --all
1176-
'
1177-
11781167
#
11791168
# version/wait tests
11801169
#

0 commit comments

Comments
 (0)