-
Task
-
-
Major
-
Resolution:
Fixed
-
-
-
From 04a3482b9c5772cd3a82a4aec51976cd2e3e686d Mon Sep 17 00:00:00 2001
|
From: Shuode Li <shuodl@microsoft.com>
|
Date: Tue, 19 Sep 2017 01:47:19 +0000
|
Subject: [PATCH] Merged PR 55490: Add linger option on TCP sockets.
|
|
Add linger option on TCP sockets.
|
|
Related work items: #73276
|
---
|
CMakeLists.txt | 5 +++++
|
include/mysql_com.h | 4 ++++
|
mysql-test/r/mysqld--help-win.result | 6 ++++++
|
sql/mysqld.cc | 10 ++++++++++
|
sql/mysqld.h | 5 +++++
|
sql/sys_vars.cc | 15 +++++++++++++++
|
tools/cmake.cmd | 4 ++++
|
7 files changed, 49 insertions(+)
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
index 90a31a48303..aa3620a07c8 100644
|
--- a/CMakeLists.txt
|
+++ b/CMakeLists.txt
|
@@ -462,6 +462,11 @@ OPTION(DISABLE_AZURE_REPLICATION
|
IF(DISABLE_AZURE_REPLICATION)
|
ADD_DEFINITIONS(-DDISABLE_AZURE_REPLICATION)
|
ENDIF()
|
+OPTION(DISABLE_TCP_LINGER
|
+ "disable tcp linger options" OFF)
|
+IF(DISABLE_TCP_LINGER)
|
+ ADD_DEFINITIONS(-DDISABLE_TCP_LINGER)
|
+ENDIF()
|
|
OPTION(DISABLE_USER_NAME_CHECK
|
"disable user name check" OFF)
|
diff --git a/include/mysql_com.h b/include/mysql_com.h
|
index 8f603d07322..8b527e91e92 100644
|
--- a/include/mysql_com.h
|
+++ b/include/mysql_com.h
|
@@ -309,6 +309,10 @@ enum enum_server_command
|
#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
|
#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
|
|
+#ifndef DISABLE_TCP_LINGER
|
+#define TCP_LINGER_TIMEOUT 10
|
+#endif
|
+
|
#define ONLY_KILL_QUERY 1
|
|
|
diff --git a/mysql-test/r/mysqld--help-win.result b/mysql-test/r/mysqld--help-win.result
|
index aee358bc2b2..351ea82a1f3 100644
|
--- a/mysql-test/r/mysqld--help-win.result
|
+++ b/mysql-test/r/mysqld--help-win.result
|
@@ -1026,6 +1026,10 @@ The following options may be given as the first argument:
|
--tc-heuristic-recover=name
|
Decision to use in heuristic recover process. Possible
|
values are COMMIT or ROLLBACK.
|
+ --tcp-linger The number of seconds the server tcp linger timeout
|
+ (Defaults to on; use --skip-tcp-linger to disable.)
|
+ --tcp-linger-timeout[=#]
|
+ The number of seconds the server tcp linger timeout
|
--thread-cache-size=#
|
How many threads we should keep in a cache for reuse
|
--thread-handling=name
|
@@ -1362,6 +1366,8 @@ sync-relay-log-info 10000
|
sysdate-is-now FALSE
|
table-open-cache-instances 1
|
tc-heuristic-recover COMMIT
|
+tcp-linger TRUE
|
+tcp-linger-timeout 10
|
thread-cache-size 9
|
thread-handling one-thread-per-connection
|
thread-stack 262144
|
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
|
index 151ffc5fcd2..0ceb4d037f2 100644
|
--- a/sql/mysqld.cc
|
+++ b/sql/mysqld.cc
|
@@ -588,6 +588,11 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
|
ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0;
|
ulong max_connections, max_connect_errors;
|
|
+#ifndef DISABLE_TCP_LINGER
|
+my_bool tcp_linger_onoff;
|
+uint tcp_linger_timeout;
|
+#endif
|
+
|
#ifndef DISABLE_SUPER_ACL_CONNECTION
|
ulong max_super_acl_connections; /* The variable define the max connection number of super user */
|
#endif
|
@@ -6499,6 +6504,11 @@ void handle_connections_sockets()
|
sleep(1); // Give other threads some time
|
continue;
|
}
|
+
|
+#ifndef DISABLE_TCP_LINGER
|
+ struct linger ling = {tcp_linger_onoff, tcp_linger_timeout};
|
+ mysql_socket_setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
|
+#endif
|
|
#ifdef HAVE_LIBWRAP
|
{
|
diff --git a/sql/mysqld.h b/sql/mysqld.h
|
index 9bd87bab9aa..b5f6b118f2d 100644
|
--- a/sql/mysqld.h
|
+++ b/sql/mysqld.h
|
@@ -222,6 +222,11 @@ extern MYSQL_PLUGIN_IMPORT ulong max_connections;
|
extern ulong max_digest_length;
|
extern ulong max_connect_errors, connect_timeout;
|
|
+#ifndef DISABLE_TCP_LINGER
|
+extern my_bool tcp_linger_onoff;
|
+extern uint tcp_linger_timeout;
|
+#endif
|
+
|
#ifndef DISABLE_SUPER_ACL_CONNECTION
|
extern ulong max_super_acl_connections;
|
#endif
|
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
|
index eba5e9005aa..1753fa016ef 100644
|
--- a/sql/sys_vars.cc
|
+++ b/sql/sys_vars.cc
|
@@ -3205,6 +3205,21 @@ static Sys_var_ulong Sys_net_wait_timeout(
|
VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)),
|
DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1));
|
|
+#ifndef DISABLE_TCP_LINGER
|
+static Sys_var_mybool Sys_tcp_linger_onoff(
|
+ "tcp_linger",
|
+ "The number of seconds the server tcp linger timeout",
|
+ GLOBAL_VAR(tcp_linger_onoff), CMD_LINE(OPT_ARG), DEFAULT(TRUE),
|
+ NO_MUTEX_GUARD, NOT_IN_BINLOG);
|
+
|
+static Sys_var_uint Sys_tcp_linger_timout(
|
+ "tcp_linger_timeout",
|
+ "The number of seconds the server tcp linger timeout",
|
+ GLOBAL_VAR(tcp_linger_timeout), CMD_LINE(OPT_ARG),
|
+ VALID_RANGE(1, 65535U),
|
+ DEFAULT(TCP_LINGER_TIMEOUT), BLOCK_SIZE(1));
|
+#endif
|
+
|
static Sys_var_plugin Sys_default_storage_engine(
|
"default_storage_engine", "The default storage engine for new tables",
|
SESSION_VAR(table_plugin), NO_CMD_LINE,
|
diff --git a/tools/cmake.cmd b/tools/cmake.cmd
|
index 0bcbc9db4fc..a48f447d257 100644
|
--- a/tools/cmake.cmd
|
+++ b/tools/cmake.cmd
|
@@ -68,6 +68,10 @@ IF NOT "x%plugin:dazurerepl=%"=="x%plugin%" (
|
SET cmakeargs=%cmakeargs% -DDISABLE_AZURE_REPLICATION=ON
|
)
|
|
+IF NOT "x%plugin:etcplinger=%"=="x%plugin%" (
|
+ SET cmakeargs=%cmakeargs% -DDISABLE_TCP_LINGER=ON
|
+)
|
+
|
IF NOT "x%plugin:dusernamecheck=%"=="x%plugin%" (
|
SET cmakeargs=%cmakeargs% -DDISABLE_USER_NAME_CHECK=ON
|
)
|
{"report":{"fcp":803.9000000357628,"ttfb":214.10000002384186,"pageVisibility":"visible","entityId":63681,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"3a401bbe-6781-4505-9738-4c4ed53f2fd3","navigationType":0,"readyForUser":897.6000000238419,"redirectCount":0,"resourceLoadedEnd":939.4000000357628,"resourceLoadedStart":219,"resourceTiming":[{"duration":136.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":219,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":219,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":355.60000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":136.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":219.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":219.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":355.80000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":147.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":219.30000001192093,"connectEnd":219.30000001192093,"connectStart":219.30000001192093,"domainLookupEnd":219.30000001192093,"domainLookupStart":219.30000001192093,"fetchStart":219.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":219.30000001192093,"responseEnd":366.5,"responseStart":366.5,"secureConnectionStart":219.30000001192093},{"duration":200.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":219.5,"connectEnd":219.5,"connectStart":219.5,"domainLookupEnd":219.5,"domainLookupStart":219.5,"fetchStart":219.5,"redirectEnd":0,"redirectStart":0,"requestStart":219.5,"responseEnd":419.80000001192093,"responseStart":419.80000001192093,"secureConnectionStart":219.5},{"duration":203.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":219.69999998807907,"connectEnd":219.69999998807907,"connectStart":219.69999998807907,"domainLookupEnd":219.69999998807907,"domainLookupStart":219.69999998807907,"fetchStart":219.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":219.69999998807907,"responseEnd":423.19999998807907,"responseStart":423.19999998807907,"secureConnectionStart":219.69999998807907},{"duration":203.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":219.9000000357628,"connectEnd":219.9000000357628,"connectStart":219.9000000357628,"domainLookupEnd":219.9000000357628,"domainLookupStart":219.9000000357628,"fetchStart":219.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":219.9000000357628,"responseEnd":423.60000002384186,"responseStart":423.60000002384186,"secureConnectionStart":219.9000000357628},{"duration":203.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":220.10000002384186,"connectEnd":220.10000002384186,"connectStart":220.10000002384186,"domainLookupEnd":220.10000002384186,"domainLookupStart":220.10000002384186,"fetchStart":220.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":220.10000002384186,"responseEnd":424,"responseStart":424,"secureConnectionStart":220.10000002384186},{"duration":282.80000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":220.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":220.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":503.10000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":204,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":220.4000000357628,"connectEnd":220.4000000357628,"connectStart":220.4000000357628,"domainLookupEnd":220.4000000357628,"domainLookupStart":220.4000000357628,"fetchStart":220.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":220.4000000357628,"responseEnd":424.4000000357628,"responseStart":424.4000000357628,"secureConnectionStart":220.4000000357628},{"duration":282.69999998807907,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":220.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":220.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":503.30000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":204.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":220.69999998807907,"connectEnd":220.69999998807907,"connectStart":220.69999998807907,"domainLookupEnd":220.69999998807907,"domainLookupStart":220.69999998807907,"fetchStart":220.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":220.69999998807907,"responseEnd":425,"responseStart":425,"secureConnectionStart":220.69999998807907},{"duration":667.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":225.69999998807907,"connectEnd":225.69999998807907,"connectStart":225.69999998807907,"domainLookupEnd":225.69999998807907,"domainLookupStart":225.69999998807907,"fetchStart":225.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":225.69999998807907,"responseEnd":892.9000000357628,"responseStart":892.9000000357628,"secureConnectionStart":225.69999998807907},{"duration":668,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":225.9000000357628,"connectEnd":225.9000000357628,"connectStart":225.9000000357628,"domainLookupEnd":225.9000000357628,"domainLookupStart":225.9000000357628,"fetchStart":225.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":225.9000000357628,"responseEnd":893.9000000357628,"responseStart":893.9000000357628,"secureConnectionStart":225.9000000357628},{"duration":138.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":528.5,"connectEnd":528.5,"connectStart":528.5,"domainLookupEnd":528.5,"domainLookupStart":528.5,"fetchStart":528.5,"redirectEnd":0,"redirectStart":0,"requestStart":528.5,"responseEnd":667.1000000238419,"responseStart":667.1000000238419,"secureConnectionStart":528.5},{"duration":176.80000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":762.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":762.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":939.3000000119209,"responseStart":0,"secureConnectionStart":0},{"duration":176.4000000357628,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":763,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":763,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":939.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":134.4000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":763.6999999880791,"connectEnd":763.6999999880791,"connectStart":763.6999999880791,"domainLookupEnd":763.6999999880791,"domainLookupStart":763.6999999880791,"fetchStart":763.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":763.6999999880791,"responseEnd":898.1000000238419,"responseStart":898.1000000238419,"secureConnectionStart":763.6999999880791},{"duration":140.4000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":764,"connectEnd":764,"connectStart":764,"domainLookupEnd":764,"domainLookupStart":764,"fetchStart":764,"redirectEnd":0,"redirectStart":0,"requestStart":764,"responseEnd":904.4000000357628,"responseStart":904.4000000357628,"secureConnectionStart":764},{"duration":141.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/86ee9bbc76cd1bcd8556fcdcf46241c9-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":764.3000000119209,"connectEnd":764.3000000119209,"connectStart":764.3000000119209,"domainLookupEnd":764.3000000119209,"domainLookupStart":764.3000000119209,"fetchStart":764.3000000119209,"redirectEnd":0,"redirectStart":0,"requestStart":764.3000000119209,"responseEnd":905.6000000238419,"responseStart":905.6000000238419,"secureConnectionStart":764.3000000119209},{"duration":183,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":798.1000000238419,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":798.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":981.1000000238419,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":35,"responseStart":214,"responseEnd":221,"domLoading":217,"domInteractive":1027,"domContentLoadedEventStart":1027,"domContentLoadedEventEnd":1074,"domComplete":1340,"loadEventStart":1340,"loadEventEnd":1341,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":989.4000000357628},{"name":"bigPipe.sidebar-id.end","time":990.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":990.3000000119209},{"name":"bigPipe.activity-panel-pipe-id.end","time":991.5},{"name":"activityTabFullyLoaded","time":1087}],"measures":[],"correlationId":"355fd389857c9d","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":13,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}