diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2017-08-30 14:24:39 +1000 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-08-30 14:24:39 +1000 |
commit | fa556f14150cce2285be628de67cc0c900a9c10c (patch) | |
tree | e5bdbab66c288f47e1db6f982eda3e6ccbcfc76b | |
parent | f49c32e6c91f2b3e479f1c41a75ef1c5c53ef669 (diff) | |
download | mongo-fa556f14150cce2285be628de67cc0c900a9c10c.tar.gz |
WT-3549 Fix a deadlock sweeping table handles. (#3630)
We need to acquire the global table lock before the table handle lock.
-rw-r--r-- | src/conn/conn_sweep.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c index 3b4e50295ec..008aa6c08d8 100644 --- a/src/conn/conn_sweep.c +++ b/src/conn/conn_sweep.c @@ -93,14 +93,8 @@ __sweep_expire_one(WT_SESSION_IMPL *session) * * For btree handles, closing the handle decrements the open file * count, meaning the close loop won't overrun the configured minimum. - * For tables, we need to hold the table lock to avoid racing with - * cursor opens. */ - if (dhandle->type == WT_DHANDLE_TYPE_TABLE) - WT_WITH_TABLE_WRITE_LOCK(session, - ret = __wt_conn_dhandle_close(session, false, true)); - else - ret = __wt_conn_dhandle_close(session, false, true); + ret = __wt_conn_dhandle_close(session, false, true); err: __wt_writeunlock(session, &dhandle->rwlock); @@ -137,8 +131,17 @@ __sweep_expire(WT_SESSION_IMPL *session, time_t now) conn->sweep_idle_time) continue; - WT_WITH_DHANDLE(session, dhandle, - ret = __sweep_expire_one(session)); + /* + * For tables, we need to hold the table lock to avoid racing + * with cursor opens. + */ + if (dhandle->type == WT_DHANDLE_TYPE_TABLE) + WT_WITH_TABLE_WRITE_LOCK(session, + WT_WITH_DHANDLE(session, dhandle, + ret = __sweep_expire_one(session))); + else + WT_WITH_DHANDLE(session, dhandle, + ret = __sweep_expire_one(session)); WT_RET_BUSY_OK(ret); } |