summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-04-18 14:53:06 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-06-01 10:40:38 +1000
commit30d327f810fd166f312d9e7b75ee747a805f4485 (patch)
treeb0add1dc9c4060af31fe46c3ad1e4c2b4653b0f1
parent88b898e7cb4ede9d1d525ae7d4edd9ab8e319f8d (diff)
downloadmongo-30d327f810fd166f312d9e7b75ee747a805f4485.tar.gz
Merge pull request #2664 from wiredtiger/wt-2559
WT-2559 Open a local log file handle for sync. (cherry picked from commit 6b3553003f32b9255fddf56045643e7076d51868)
-rw-r--r--src/log/log.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/log/log.c b/src/log/log.c
index 1132b54f335..b43cc56a908 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -8,6 +8,8 @@
#include "wt_internal.h"
+static int __log_openfile(
+ WT_SESSION_IMPL *, bool, WT_FH **, const char *, uint32_t);
static int __log_write_internal(
WT_SESSION_IMPL *, WT_ITEM *, WT_LSN *, uint32_t);
@@ -93,8 +95,9 @@ __wt_log_background(WT_SESSION_IMPL *session, WT_LSN *lsn)
int
__wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn)
{
- WT_LOG *log;
WT_DECL_RET;
+ WT_FH *log_fh;
+ WT_LOG *log;
log = S2C(session)->log;
@@ -129,12 +132,21 @@ __wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn)
* Sync the log file if needed.
*/
if (__wt_log_cmp(&log->sync_lsn, min_lsn) < 0) {
+ /*
+ * Get our own file handle to the log file. It is possible
+ * for the file handle in the log structure to change out
+ * from under us and either be NULL or point to a different
+ * file than we want.
+ */
+ WT_ERR(__log_openfile(session,
+ false, &log_fh, WT_LOG_FILENAME, min_lsn->l.file));
WT_ERR(__wt_verbose(session, WT_VERB_LOG,
"log_force_sync: sync %s to LSN %" PRIu32 "/%" PRIu32,
- log->log_fh->name, min_lsn->l.file, min_lsn->l.offset));
- WT_ERR(__wt_fsync(session, log->log_fh, true));
+ log_fh->name, min_lsn->l.file, min_lsn->l.offset));
+ WT_ERR(__wt_fsync(session, log_fh, true));
log->sync_lsn = *min_lsn;
WT_STAT_FAST_CONN_INCR(session, log_sync);
+ WT_ERR(__wt_close(session, &log_fh));
WT_ERR(__wt_cond_signal(session, log->log_sync_cond));
}
err: