diff options
Diffstat (limited to 'src/conn/conn_ckpt.c')
-rw-r--r-- | src/conn/conn_ckpt.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c index b4913043d63..faeef4e71a2 100644 --- a/src/conn/conn_ckpt.c +++ b/src/conn/conn_ckpt.c @@ -87,22 +87,36 @@ __ckpt_server(void *arg) */ __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs); - /* Checkpoint the database. */ - WT_ERR(wt_session->checkpoint(wt_session, NULL)); - - /* Reset. */ - if (conn->ckpt_logsize) { - __wt_log_written_reset(session); - conn->ckpt_signalled = false; - - /* - * In case we crossed the log limit during the - * checkpoint and the condition variable was already - * signalled, do a tiny wait to clear it so we don't do - * another checkpoint immediately. - */ - __wt_cond_wait(session, conn->ckpt_cond, 1); - } + /* + * Checkpoint the database if the connection is marked dirty. + * A connection is marked dirty whenever a btree gets marked + * dirty, which reflects upon a change in the database that + * needs to be checkpointed. Said that, there can be short + * instances when a btree gets marked dirty and the connection + * is yet to be. We might skip a checkpoint in that short + * instance, which is okay because by the next time we get to + * checkpoint, the connection would have been marked dirty and + * hence the checkpoint will not be skipped this time. + */ + if (conn->modified) { + WT_ERR(wt_session->checkpoint(wt_session, NULL)); + + /* Reset. */ + if (conn->ckpt_logsize) { + __wt_log_written_reset(session); + conn->ckpt_signalled = false; + + /* + * In case we crossed the log limit during the + * checkpoint and the condition variable was + * already signalled, do a tiny wait to clear + * it so we don't do another checkpoint + * immediately. + */ + __wt_cond_wait(session, conn->ckpt_cond, 1); + } + } else + WT_STAT_CONN_INCR(session, txn_checkpoint_skipped); } if (0) { |