From 1a5cb534d9e72b92f93496bd4caf2c2c3468deb0 Mon Sep 17 00:00:00 2001 From: Michal Jarzabek Date: Sun, 15 Jan 2017 15:32:04 +0000 Subject: [PATCH] mds/Server.cc: Don't evict a slow client if... ... it's the only client Fixes: http://tracker.ceph.com/issues/17855 Signed-off-by: Michal Jarzabek --- qa/tasks/cephfs/test_misc.py | 39 ++++++++++++++++++++++++++++++++++++ src/mds/Server.cc | 7 +++++++ 2 files changed, 46 insertions(+) diff --git a/qa/tasks/cephfs/test_misc.py b/qa/tasks/cephfs/test_misc.py index 3f98c3719b8..a48e0a2a63b 100644 --- a/qa/tasks/cephfs/test_misc.py +++ b/qa/tasks/cephfs/test_misc.py @@ -4,9 +4,14 @@ from tasks.cephfs.fuse_mount import FuseMount from tasks.cephfs.cephfs_test_case import CephFSTestCase from teuthology.orchestra.run import CommandFailedError import errno +import time class TestMisc(CephFSTestCase): CLIENTS_REQUIRED = 2 + + LOAD_SETTINGS = ["mds_session_autoclose"] + mds_session_autoclose = None + def test_getattr_caps(self): """ Check if MDS recognizes the 'mask' parameter of open request. @@ -89,3 +94,37 @@ class TestMisc(CephFSTestCase): self.fs.mon_manager.raw_cluster_cmd('fs', 'new', self.fs.name, self.fs.metadata_pool_name, data_pool_name) + + def test_evict_client(self): + """ + Check that a slow client session won't get evicted if it's the + only session + """ + + self.mount_b.umount_wait(); + ls_data = self.fs.mds_asok(['session', 'ls']) + self.assert_session_count(1, ls_data) + + self.mount_a.kill(); + self.mount_a.kill_cleanup(); + + time.sleep(self.mds_session_autoclose * 1.5) + ls_data = self.fs.mds_asok(['session', 'ls']) + self.assert_session_count(1, ls_data) + + self.mount_a.mount() + self.mount_a.wait_until_mounted() + self.mount_b.mount() + self.mount_b.wait_until_mounted() + + ls_data = self._session_list() + self.assert_session_count(2, ls_data) + + self.mount_a.kill() + self.mount_a.kill() + self.mount_b.kill_cleanup() + self.mount_b.kill_cleanup() + + time.sleep(self.mds_session_autoclose * 1.5) + ls_data = self.fs.mds_asok(['session', 'ls']) + self.assert_session_count(1, ls_data) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d62720b4609..48e1e5aa030 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -651,6 +651,13 @@ void Server::find_idle_sessions() return; } + if (mds->sessionmap.get_sessions().size() == 1 && + mds->mdsmap->get_num_in_mds() == 1) { + dout(20) << "not evicting a slow client, because there is only one" + << dendl; + return; + } + while (1) { Session *session = mds->sessionmap.get_oldest_session(Session::STATE_STALE); if (!session)