diff --git a/ft/cachetable/cachetable.cc b/ft/cachetable/cachetable.cc index 5bba977de..a8578d29e 100644 --- a/ft/cachetable/cachetable.cc +++ b/ft/cachetable/cachetable.cc @@ -336,6 +336,11 @@ int toku_cachefile_of_filenum (CACHETABLE ct, FILENUM filenum, CACHEFILE *cf) { return ct->cf_list.cachefile_of_filenum(filenum, cf); } +// Check a cachefile is in checkpoint or NOT +bool toku_cachefile_forcheckpoint(CACHEFILE cf) { + return cf->for_checkpoint; +} + // TEST-ONLY function // If something goes wrong, close the fd. After this, the caller shouldn't close the fd, but instead should close the cachefile. int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char *fname_in_env) { diff --git a/ft/cachetable/cachetable.h b/ft/cachetable/cachetable.h index 148326562..9842459b7 100644 --- a/ft/cachetable/cachetable.h +++ b/ft/cachetable/cachetable.h @@ -138,6 +138,9 @@ int toku_cachefile_of_filenum (CACHETABLE t, FILENUM filenum, CACHEFILE *cf); // During a transaction, we cannot reuse an iname. int toku_cachefile_of_iname_in_env (CACHETABLE ct, const char *iname_in_env, CACHEFILE *cf); +// Check a cachefile is in checkpoint or NOT +bool toku_cachefile_forcheckpoint(CACHEFILE cf); + // Get the iname (within the cwd) associated with the cachefile // Return the filename char *toku_cachefile_fname_in_cwd (CACHEFILE cf); diff --git a/ft/ft.cc b/ft/ft.cc index 2a0fb6f68..b2a44f4f3 100644 --- a/ft/ft.cc +++ b/ft/ft.cc @@ -256,7 +256,9 @@ static void ft_close(CACHEFILE cachefile, int fd, void *header_v, bool oplsn_val } if (ft->h->dirty) { // this is the only place this bit is tested (in currentheader) bool do_checkpoint = true; - if (logger && logger->rollback_cachefile == cachefile) { + bool for_checkpoint = toku_cachefile_forcheckpoint(cachefile); + // It would be better for FT to update header only in checkpoint, so all FT files keep consistency before next checkpoint. + if ((!for_checkpoint) || (logger && logger->rollback_cachefile == cachefile)) { do_checkpoint = false; } if (do_checkpoint) {