From 6b3704990257643da54100d8581856a7d2c72f86 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 17 Feb 2015 12:12:11 +0100 Subject: socket: use TCP_USER_TIMEOUT to detect client failures quicker Use the network.ping-timeout to set the TCP_USER_TIMEOUT socket option (see 'man 7 tcp'). The option sets the transport.tcp-user-timeout option that is handled in the rpc/socket layer on the protocol/server side. This socket option makes detecting unclean disconnected clients more reliable. When the socket gets closed, any locks that the client held are been released. This makes it possible to reduce the fail-over time for applications that run on systems that became unreachable due to a network partition or general system error client-side (kernel panic, hang, ...). It is not trivial to create a test-case for this at the moment. We need a client that unclean disconnects and an other client that tries to take over the lock from the disconnected client. URL: http://supercolony.gluster.org/pipermail/gluster-devel/2014-May/040755.html Change-Id: I5e5f540a49abfb5f398291f1818583a63a5f4bb4 BUG: 1129787 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/8065 Tested-by: Gluster Build System Reviewed-by: soumya k Reviewed-by: Santosh Pradhan Reviewed-by: Kaleb KEITHLEY --- xlators/mgmt/glusterd/src/glusterd-handler.c | 12 +++++++++--- xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index cc97baf6f21..1c33f3febb3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -2994,7 +2994,8 @@ out: } int -glusterd_transport_keepalive_options_get (int *interval, int *time) +glusterd_transport_keepalive_options_get (int *interval, int *time, + int *timeout) { int ret = 0; xlator_t *this = NULL; @@ -3008,6 +3009,9 @@ glusterd_transport_keepalive_options_get (int *interval, int *time) ret = dict_get_int32 (this->options, "transport.socket.keepalive-time", time); + ret = dict_get_int32 (this->options, + "transport.tcp-user-timeout", + timeout); return 0; } @@ -3018,6 +3022,7 @@ glusterd_transport_inet_options_build (dict_t **options, const char *hostname, dict_t *dict = NULL; int32_t interval = -1; int32_t time = -1; + int32_t timeout = -1; int ret = 0; GF_ASSERT (options); @@ -3044,10 +3049,11 @@ glusterd_transport_inet_options_build (dict_t **options, const char *hostname, } /* Set keepalive options */ - glusterd_transport_keepalive_options_get (&interval, &time); + glusterd_transport_keepalive_options_get (&interval, &time, &timeout); if ((interval > 0) || (time > 0)) - ret = rpc_transport_keepalive_options_set (dict, interval, time); + ret = rpc_transport_keepalive_options_set (dict, interval, + time, timeout); *options = dict; out: gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 77f6853dd51..b0a3b0c8c39 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -842,6 +842,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { }, /* Server xlator options */ + { .key = "network.ping-timeout", + .voltype = "protocol/server", + .option = "transport.tcp-user-timeout", + .op_version = GD_OP_VERSION_3_7_0, + }, { .key = "network.tcp-window-size", .voltype = "protocol/server", .op_version = 1 -- cgit