From 5f705a446360101e54e7df756ccd938ce424122a Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Thu, 21 Jan 2010 18:42:50 +0000 Subject: [PATCH] skip the log force when TforceCommits() is called and the entire log has already been forced. The old behavior generated a redundant CRC entry and force wrote it. --- src/stasis/logger/groupForce.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stasis/logger/groupForce.c b/src/stasis/logger/groupForce.c index 21ae008..4cb823b 100644 --- a/src/stasis/logger/groupForce.c +++ b/src/stasis/logger/groupForce.c @@ -51,9 +51,15 @@ void stasis_log_group_force(stasis_log_group_force_t* lh, lsn_t lsn) { // static int pendingCommits; pthread_mutex_lock(&lh->check_commit); + lsn_t first_unstable = lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT); + lsn_t next_available = lh->log->next_available_lsn(lh->log); + DEBUG(stderr, "state: lsn=%lld first_unstable=%lld next_available=%lld\n", + lsn, first_unstable, next_available); if(lsn == INVALID_LSN) { - lsn = lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT); - } else if(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn) { + lsn = next_available - 1; + } + if(first_unstable > lsn || first_unstable == next_available) { + DEBUG(stderr, "skipped group force\n"); pthread_mutex_unlock(&lh->check_commit); return; }