Skip to content

Commit e1f7562

Browse files
committed
kvs: call content.flush before checkpoint
Problem: When the KVS module is unloaded, a checkpoint of the root reference is attempted. However, a content.flush is not done beforehand. This could result in an invalid checkpoint reference as data is not guaranteed to be flushed to the backing store. Solution: Call content.flush before checkpointing. Fixes #6237
1 parent 7e86aeb commit e1f7562

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/modules/content/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* The callback is synchronized with the instance heartbeat, with a
3535
* sync period upper bound set to 'sync_max' seconds.
3636
*/
37-
static double sync_max = 10.;
37+
static double sync_max = 100.;
3838

3939
static const char *default_hash = "sha1";
4040

src/modules/kvs/kvs.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,15 +2914,27 @@ static int checkpoint_get (flux_t *h, char *buf, size_t len, int *seq)
29142914
*/
29152915
static int checkpoint_put (flux_t *h, const char *rootref, int rootseq)
29162916
{
2917-
flux_future_t *f = NULL;
2917+
flux_future_t *fcf = NULL;
2918+
flux_future_t *fcc = NULL;
29182919
int rv = -1;
29192920

2920-
if (!(f = kvs_checkpoint_commit (h, NULL, rootref, rootseq, 0, 0))
2921-
|| flux_rpc_get (f, NULL) < 0)
2921+
/* first must ensure all content is flushed */
2922+
if (!(fcf = flux_rpc (h, "content.flush", NULL, 0, 0))
2923+
|| flux_rpc_get (fcf, NULL) < 0) {
2924+
/* fallthrough to kvs_checkpoint_commit(), we may wish to checkpoint
2925+
* only to the content layer
2926+
*/
2927+
if (errno != ENOSYS)
2928+
goto error;
2929+
}
2930+
2931+
if (!(fcc = kvs_checkpoint_commit (h, NULL, rootref, rootseq, 0, 0))
2932+
|| flux_rpc_get (fcc, NULL) < 0)
29222933
goto error;
29232934
rv = 0;
29242935
error:
2925-
flux_future_destroy (f);
2936+
flux_future_destroy (fcf);
2937+
flux_future_destroy (fcc);
29262938
return rv;
29272939
}
29282940

t/t0028-content-backing-none.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ test_expect_success 'load kvs and create some kvs data' '
5454
'
5555

5656
test_expect_success 'reload kvs' '
57-
flux module reload kvs &&
57+
flux module reload kvs
58+
flux kvs get a &&
5859
test $(flux kvs get a) = "1" &&
5960
test $(flux kvs get b) = "foo"
6061
'

0 commit comments

Comments
 (0)