summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-05-04 14:43:53 +1000
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-05-04 14:43:53 +1000
commit1778159b319620941823ee8ea73623c92b623c00 (patch)
treeedb4257e567c93c72d4c653ec4ebee59860439ef
parentea18eacff24cfecbe58f3e8312eda1fc5cd2dce9 (diff)
downloadmongo-1778159b319620941823ee8ea73623c92b623c00.tar.gz
WT-2616 Fix a deadlock with in-memory size lookups. (#2716)
-rw-r--r--src/os_common/os_fs_inmemory.c12
-rw-r--r--test/suite/test_stat05.py5
2 files changed, 13 insertions, 4 deletions
diff --git a/src/os_common/os_fs_inmemory.c b/src/os_common/os_fs_inmemory.c
index 682d3f0c811..2ef24fb2633 100644
--- a/src/os_common/os_fs_inmemory.c
+++ b/src/os_common/os_fs_inmemory.c
@@ -262,14 +262,20 @@ __im_fs_size(WT_FILE_SYSTEM *file_system,
im_fs = (WT_FILE_SYSTEM_INMEM *)file_system;
session = (WT_SESSION_IMPL *)wt_session;
+ /*
+ * Search for the handle, then get its size. Take care to release the
+ * global lock before getting the size or we will self-deadlock.
+ */
__wt_spin_lock(session, &im_fs->lock);
+ im_fh = __im_handle_search(file_system, name);
+ __wt_spin_unlock(session, &im_fs->lock);
- ret = ENOENT;
- if ((im_fh = __im_handle_search(file_system, name)) != NULL)
+ if (im_fh == NULL)
+ ret = ENOENT;
+ else
ret = __im_file_size(
(WT_FILE_HANDLE *)im_fh, wt_session, sizep);
- __wt_spin_unlock(session, &im_fs->lock);
return (ret);
}
diff --git a/test/suite/test_stat05.py b/test/suite/test_stat05.py
index 6a93ec2c84d..9bcedd65089 100644
--- a/test/suite/test_stat05.py
+++ b/test/suite/test_stat05.py
@@ -37,9 +37,13 @@ from helper import complex_value_populate, key_populate, value_populate
# Statistics cursor using size only
class test_stat_cursor_config(wttest.WiredTigerTestCase):
pfx = 'test_stat_cursor_size'
+ conn_config = 'statistics=(fast)'
+
uri = [
('file', dict(uri='file:' + pfx, pop=simple_populate, cfg='')),
('table', dict(uri='table:' + pfx, pop=simple_populate, cfg='')),
+ ('inmem', dict(uri='table:' + pfx, pop=simple_populate, cfg='',
+ conn_config='in_memory,statistics=(fast)')),
('table-lsm', dict(uri='table:' + pfx, pop=simple_populate,
cfg=',type=lsm,lsm=(chunk_size=1MB,merge_min=2)')),
('complex', dict(uri='table:' + pfx, pop=complex_populate, cfg='')),
@@ -49,7 +53,6 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(uri)
- conn_config = 'statistics=(fast)'
def openAndWalkStatCursor(self):
c = self.session.open_cursor(