Skip to content

Commit 76e9d9f

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 0868ed9 commit 76e9d9f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/modules/kvs/kvs.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,15 +2914,28 @@ 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 *f1 = NULL;
2918+
flux_future_t *f2 = 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 (!(f1 = flux_rpc (h, "content.flush", NULL, 0, 0))
2923+
|| flux_rpc_get (f1, NULL) < 0) {
2924+
/* fallthrough to kvs_checkpoint_commit(), ENOSYS may be due
2925+
* to no backing store, but checkpoint can still be done to
2926+
* content cache.
2927+
*/
2928+
if (errno != ENOSYS)
2929+
goto error;
2930+
}
2931+
2932+
if (!(f2 = kvs_checkpoint_commit (h, NULL, rootref, rootseq, 0, 0))
2933+
|| flux_rpc_get (f2, NULL) < 0)
29222934
goto error;
29232935
rv = 0;
29242936
error:
2925-
flux_future_destroy (f);
2937+
flux_future_destroy (f1);
2938+
flux_future_destroy (f2);
29262939
return rv;
29272940
}
29282941

0 commit comments

Comments
 (0)