Skip to content

Commit

Permalink
kvs: call content.flush before checkpoint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chu11 committed Aug 27, 2024
1 parent 7e86aeb commit e1f7562
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/modules/content/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* The callback is synchronized with the instance heartbeat, with a
* sync period upper bound set to 'sync_max' seconds.
*/
static double sync_max = 10.;
static double sync_max = 100.;

static const char *default_hash = "sha1";

Expand Down
20 changes: 16 additions & 4 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2914,15 +2914,27 @@ static int checkpoint_get (flux_t *h, char *buf, size_t len, int *seq)
*/
static int checkpoint_put (flux_t *h, const char *rootref, int rootseq)
{
flux_future_t *f = NULL;
flux_future_t *fcf = NULL;
flux_future_t *fcc = NULL;
int rv = -1;

if (!(f = kvs_checkpoint_commit (h, NULL, rootref, rootseq, 0, 0))
|| flux_rpc_get (f, NULL) < 0)
/* first must ensure all content is flushed */
if (!(fcf = flux_rpc (h, "content.flush", NULL, 0, 0))
|| flux_rpc_get (fcf, NULL) < 0) {
/* fallthrough to kvs_checkpoint_commit(), we may wish to checkpoint
* only to the content layer
*/
if (errno != ENOSYS)
goto error;
}

if (!(fcc = kvs_checkpoint_commit (h, NULL, rootref, rootseq, 0, 0))
|| flux_rpc_get (fcc, NULL) < 0)
goto error;
rv = 0;
error:
flux_future_destroy (f);
flux_future_destroy (fcf);
flux_future_destroy (fcc);
return rv;
}

Expand Down
3 changes: 2 additions & 1 deletion t/t0028-content-backing-none.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ test_expect_success 'load kvs and create some kvs data' '
'

test_expect_success 'reload kvs' '
flux module reload kvs &&
flux module reload kvs
flux kvs get a &&
test $(flux kvs get a) = "1" &&
test $(flux kvs get b) = "foo"
'
Expand Down

0 comments on commit e1f7562

Please sign in to comment.