From 14e24da1eb59a85fe99c22bafd8641ca2b75a923 Mon Sep 17 00:00:00 2001 From: Shreyas Siravara Date: Mon, 28 Mar 2016 14:17:53 -0700 Subject: event: Idle connection management Summary: - This diff adds support for detecting and tracking idle client connections. - It allows *service translators* (server, nfs) to opt-in to detect and close idle client connections. - Right now it explicitly restricts the service to NFS as a safety. Here are the debug logs when a client connection gets closed: [2016-03-29 17:27:06.154232] W [socket.c:2426:socket_timeout_handler] 0-socket: Shutting down idle client connection (idle=20s,fd=20,conn=[2401:db00:11:d0af:face:0:3:0:957]->[2401:db00:11:d0af:face:0:3:0:2049])! [2016-03-29 17:27:06.154292] D [event-epoll.c:655:__event_epoll_timeout_slot] 0-epoll: Connection on slot->fd=9 was idle for 20 seconds! [2016-03-29 17:27:06.163282] D [socket.c:629:__socket_rwv] 0-socket.nfs-server: EOF on socket [2016-03-29 17:27:06.163298] D [socket.c:2474:socket_event_handler] 0-transport: disconnecting now [2016-03-29 17:27:06.163316] D [event-epoll.c:614:event_dispatch_epoll_handler] 0-epoll: generation bumped on idx=9 from gen=4 to slot->gen=5, fd=20, slot->fd=20 Test Plan: - Used stuck NFS mounts to create idle clients and unstuck them. Reviewers: kvigor, rwareing Reviewed By: rwareing Subscribers: dld, moox, dph Differential Revision: https://phabricator.fb.com/D3112099 Change-Id: Ic06c89e03f87daabab7f07f892390edd1a1fcc20 Signed-off-by: Jeff Darcy Reviewed-on: https://review.gluster.org/18265 Reviewed-by: Jeff Darcy Tested-by: Jeff Darcy CentOS-regression: Gluster Build System Smoke: Gluster Build System --- tests/basic/nfs-idle-connections.t | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/basic/nfs-idle-connections.t (limited to 'tests') diff --git a/tests/basic/nfs-idle-connections.t b/tests/basic/nfs-idle-connections.t new file mode 100644 index 00000000000..0a6d6e5daf7 --- /dev/null +++ b/tests/basic/nfs-idle-connections.t @@ -0,0 +1,38 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +cleanup; + +>/var/log/glusterfs/nfs.log; + + +function check_connection_log () +{ + if grep "$1" /var/log/glusterfs/nfs.log &> /dev/null; then + echo "Y" + else + echo "N" + fi; +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2} +TEST $CLI volume set $V0 nfs.disable off +TEST $CLI volume start $V0 +TEST $CLI volume set $V0 nfs.client-max-idle-seconds 6; + +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available; + +TEST mount -overs=3,noac,noacl,noatime,nolock,timeo=200 $HOSTNAME:/$V0 $N0 + +EXPECT_WITHIN 25 "Y" check_connection_log "Found idle client connection"; + +TEST $CLI volume set $V0 nfs.close-idle-clients on + +EXPECT_WITHIN 25 "Y" check_connection_log "Shutting down idle client connection"; + +cleanup; -- cgit