diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c index 3157f6d6af5..c77cbf39cd1 100644 --- a/src/conn/conn_log.c +++ b/src/conn/conn_log.c @@ -511,7 +511,7 @@ typedef struct { * write_lsn in LSN order after the buffer is written to the log file. */ int -__wt_log_wrlsn(WT_SESSION_IMPL *session) +__wt_log_wrlsn(WT_SESSION_IMPL *session, int *yield) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; @@ -550,6 +550,8 @@ __wt_log_wrlsn(WT_SESSION_IMPL *session) * based on the release LSN, and then look for them in order. */ if (written_i > 0) { + if (yield != NULL) + *yield = 0; WT_INSERTION_SORT(written, written_i, WT_LOG_WRLSN_ENTRY, WT_WRLSN_ENTRY_CMP_LT); /* @@ -660,22 +662,30 @@ __log_wrlsn_server(void *arg) WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_SESSION_IMPL *session; + int yield; session = arg; conn = S2C(session); + yield = 0; while (F_ISSET(conn, WT_CONN_LOG_SERVER_RUN)) { /* * Write out any log record buffers. */ - WT_ERR(__wt_log_wrlsn(session)); - WT_ERR(__wt_cond_wait(session, conn->log_wrlsn_cond, 10000)); + WT_ERR(__wt_log_wrlsn(session, &yield)); + /* + * If __wt_log_wrlsn did work we want to yield instead of sleep. + */ + if (yield++ < 1000) + __wt_yield(); + else + WT_ERR(__wt_cond_wait(session, conn->log_wrlsn_cond, 10000)); } /* * On close we need to do this one more time because there could * be straggling log writes that need to be written. */ WT_ERR(__wt_log_force_write(session, 1)); - WT_ERR(__wt_log_wrlsn(session)); + WT_ERR(__wt_log_wrlsn(session, NULL)); if (0) { err: __wt_err(session, ret, "log wrlsn server error"); } diff --git a/src/include/extern.h b/src/include/extern.h index 822ce9d4979..cfa460b06c3 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -261,7 +261,7 @@ extern int __wt_connection_init(WT_CONNECTION_IMPL *conn); extern int __wt_connection_destroy(WT_CONNECTION_IMPL *conn); extern int __wt_logmgr_reconfig(WT_SESSION_IMPL *session, const char **cfg); extern int __wt_log_truncate_files( WT_SESSION_IMPL *session, WT_CURSOR *cursor, const char *cfg[]); -extern int __wt_log_wrlsn(WT_SESSION_IMPL *session); +extern int __wt_log_wrlsn(WT_SESSION_IMPL *session, int *yield); extern int __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_logmgr_open(WT_SESSION_IMPL *session); extern int __wt_logmgr_destroy(WT_SESSION_IMPL *session); diff --git a/src/log/log.c b/src/log/log.c index 935bdeaa7d5..601cbdc023d 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -47,7 +47,7 @@ __wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, bool start) conn = S2C(session); log = conn->log; WT_RET(__wt_log_force_write(session, 1)); - WT_RET(__wt_log_wrlsn(session)); + WT_RET(__wt_log_wrlsn(session, NULL)); if (start) *lsn = log->write_start_lsn; else @@ -771,7 +771,7 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SLOT)); while (log->log_close_fh != NULL) { WT_STAT_FAST_CONN_INCR(session, log_close_yields); - WT_RET(__wt_log_wrlsn(session)); + WT_RET(__wt_log_wrlsn(session, NULL)); if (++yield_cnt > 10000) return (EBUSY); __wt_yield();