Skip to content

Commit 7ec1949

Browse files
committed
kvs: remove dropcache
Problem: KVS dropcache code was added very early on in KVS prototyping for testing. It is basically not used anymore. If we want to test something that requires a "clean" slate for the KVS, we can just start a new instance and test with that. Solution: Remove all KVS dropcache code. Remove all associated tests. Update one regression test to be accomplished through two instances rather than one to emulate an emptying of the cache. Fixes #6608
1 parent fc1413b commit 7ec1949

File tree

5 files changed

+37
-115
lines changed

5 files changed

+37
-115
lines changed

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
#

t/t1005-kvs-security.t

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ test_expect_success 'kvs: guest cannot make a symlink in the test ns on rank 1'
379379
# Basic tests, user can't perform non-namespace operations
380380
#
381381

382-
test_expect_success 'kvs: dropcache fails (user)' '
383-
set_userid 9999 &&
384-
! flux kvs dropcache &&
385-
unset_userid
386-
'
387-
388382
test_expect_success 'kvs: stats works (user)' '
389383
set_userid 9999 &&
390384
flux module stats kvs >/dev/null &&

0 commit comments

Comments
 (0)