MDEV-14412 Support TCP keepalive options
Based on pull request by Oleg Obleukhov https://github.com/MariaDB/server/pull/400
This commit is contained in:
parent
faee08c10c
commit
e0a00c5a2f
@ -51,6 +51,14 @@ enum enum_vio_io_event
|
|||||||
VIO_IO_EVENT_CONNECT
|
VIO_IO_EVENT_CONNECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct vio_keepalive_opts
|
||||||
|
{
|
||||||
|
int interval;
|
||||||
|
int idle;
|
||||||
|
int probes;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#define VIO_LOCALHOST 1U /* a localhost connection */
|
#define VIO_LOCALHOST 1U /* a localhost connection */
|
||||||
#define VIO_BUFFERED_READ 2U /* use buffered read */
|
#define VIO_BUFFERED_READ 2U /* use buffered read */
|
||||||
#define VIO_READ_BUFFER_SIZE 16384U /* size of read buffer */
|
#define VIO_READ_BUFFER_SIZE 16384U /* size of read buffer */
|
||||||
@ -84,6 +92,7 @@ my_bool vio_is_blocking(Vio *vio);
|
|||||||
int vio_fastsend(Vio *vio);
|
int vio_fastsend(Vio *vio);
|
||||||
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
|
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
|
||||||
int vio_keepalive(Vio *vio, my_bool onoff);
|
int vio_keepalive(Vio *vio, my_bool onoff);
|
||||||
|
int vio_set_keepalive_options(Vio * vio, const struct vio_keepalive_opts *opts);
|
||||||
/* Whenever we should retry the last read/write operation. */
|
/* Whenever we should retry the last read/write operation. */
|
||||||
my_bool vio_should_retry(Vio *vio);
|
my_bool vio_should_retry(Vio *vio);
|
||||||
/* Check that operation was timed out */
|
/* Check that operation was timed out */
|
||||||
@ -214,7 +223,6 @@ enum SSL_type
|
|||||||
SSL_TYPE_SPECIFIED
|
SSL_TYPE_SPECIFIED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* HFTODO - hide this if we don't want client in embedded server */
|
/* HFTODO - hide this if we don't want client in embedded server */
|
||||||
/* This structure is for every connection on both sides */
|
/* This structure is for every connection on both sides */
|
||||||
struct st_vio
|
struct st_vio
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/mysql-test/r/mysqld--help.result
|
--- a/mysql-test/r/mysqld--help.result
|
||||||
+++ b/mysql-test/r/mysqld--help.result
|
+++ b/mysql-test/r/mysqld--help.result
|
||||||
@@ -334,7 +334,6 @@
|
@@ -381,7 +381,6 @@
|
||||||
The number of segments in a key cache
|
The number of segments in a key cache
|
||||||
-L, --language=name Client error messages in given language. May be given as
|
-L, --language=name Client error messages in given language. May be given as
|
||||||
a full path. Deprecated. Use --lc-messages-dir instead.
|
a full path. Deprecated. Use --lc-messages-dir instead.
|
||||||
@ -8,7 +8,7 @@
|
|||||||
--lc-messages=name Set the language used for the error messages.
|
--lc-messages=name Set the language used for the error messages.
|
||||||
-L, --lc-messages-dir=name
|
-L, --lc-messages-dir=name
|
||||||
Directory where error messages are
|
Directory where error messages are
|
||||||
@@ -543,6 +542,7 @@
|
@@ -602,6 +601,7 @@
|
||||||
Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME,
|
Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME,
|
||||||
DATETIME, TIMESTAMP columns.
|
DATETIME, TIMESTAMP columns.
|
||||||
(Defaults to on; use --skip-mysql56-temporal-format to disable.)
|
(Defaults to on; use --skip-mysql56-temporal-format to disable.)
|
||||||
@ -16,7 +16,7 @@
|
|||||||
--net-buffer-length=#
|
--net-buffer-length=#
|
||||||
Buffer length for TCP/IP and socket communication
|
Buffer length for TCP/IP and socket communication
|
||||||
--net-read-timeout=#
|
--net-read-timeout=#
|
||||||
@@ -957,6 +957,9 @@
|
@@ -1020,6 +1020,9 @@
|
||||||
characteristics (isolation level, read only/read
|
characteristics (isolation level, read only/read
|
||||||
write,snapshot - but not any work done / data modified
|
write,snapshot - but not any work done / data modified
|
||||||
within the transaction).
|
within the transaction).
|
||||||
@ -26,7 +26,7 @@
|
|||||||
--show-slave-auth-info
|
--show-slave-auth-info
|
||||||
Show user and password in SHOW SLAVE HOSTS on this
|
Show user and password in SHOW SLAVE HOSTS on this
|
||||||
master.
|
master.
|
||||||
@@ -1069,6 +1072,10 @@
|
@@ -1132,6 +1135,10 @@
|
||||||
Log slow queries to given log file. Defaults logging to
|
Log slow queries to given log file. Defaults logging to
|
||||||
'hostname'-slow.log. Must be enabled to activate other
|
'hostname'-slow.log. Must be enabled to activate other
|
||||||
slow log options
|
slow log options
|
||||||
@ -37,15 +37,15 @@
|
|||||||
--socket=name Socket file to use for connection
|
--socket=name Socket file to use for connection
|
||||||
--sort-buffer-size=#
|
--sort-buffer-size=#
|
||||||
Each thread that needs to do a sort allocates a buffer of
|
Each thread that needs to do a sort allocates a buffer of
|
||||||
@@ -1087,6 +1094,7 @@
|
@@ -1151,6 +1158,7 @@
|
||||||
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH
|
EMPTY_STRING_IS_NULL
|
||||||
--stack-trace Print a symbolic stack trace on failure
|
--stack-trace Print a symbolic stack trace on failure
|
||||||
(Defaults to on; use --skip-stack-trace to disable.)
|
(Defaults to on; use --skip-stack-trace to disable.)
|
||||||
+ --standalone Dummy option to start as a standalone program (NT).
|
+ --standalone Dummy option to start as a standalone program (NT).
|
||||||
--standard-compliant-cte
|
--standard-compliant-cte
|
||||||
Allow only CTEs compliant to SQL standard
|
Allow only CTEs compliant to SQL standard
|
||||||
(Defaults to on; use --skip-standard-compliant-cte to disable.)
|
(Defaults to on; use --skip-standard-compliant-cte to disable.)
|
||||||
@@ -1134,6 +1142,11 @@
|
@@ -1214,6 +1222,11 @@
|
||||||
--thread-pool-max-threads=#
|
--thread-pool-max-threads=#
|
||||||
Maximum allowed number of worker threads in the thread
|
Maximum allowed number of worker threads in the thread
|
||||||
pool
|
pool
|
||||||
@ -57,7 +57,7 @@
|
|||||||
--thread-pool-oversubscribe=#
|
--thread-pool-oversubscribe=#
|
||||||
How many additional active worker threads in a group are
|
How many additional active worker threads in a group are
|
||||||
allowed.
|
allowed.
|
||||||
@@ -1172,8 +1185,8 @@
|
@@ -1252,8 +1265,8 @@
|
||||||
automatically convert it to an on-disk MyISAM or Aria
|
automatically convert it to an on-disk MyISAM or Aria
|
||||||
table.
|
table.
|
||||||
-t, --tmpdir=name Path for temporary files. Several paths may be specified,
|
-t, --tmpdir=name Path for temporary files. Several paths may be specified,
|
||||||
@ -68,7 +68,7 @@
|
|||||||
--transaction-alloc-block-size=#
|
--transaction-alloc-block-size=#
|
||||||
Allocation block size for transactions to be stored in
|
Allocation block size for transactions to be stored in
|
||||||
binary log
|
binary log
|
||||||
@@ -1298,7 +1311,6 @@
|
@@ -1387,7 +1400,6 @@
|
||||||
key-cache-division-limit 100
|
key-cache-division-limit 100
|
||||||
key-cache-file-hash-size 512
|
key-cache-file-hash-size 512
|
||||||
key-cache-segments 0
|
key-cache-segments 0
|
||||||
@ -76,7 +76,7 @@
|
|||||||
lc-messages en_US
|
lc-messages en_US
|
||||||
lc-messages-dir MYSQL_SHAREDIR/
|
lc-messages-dir MYSQL_SHAREDIR/
|
||||||
lc-time-names en_US
|
lc-time-names en_US
|
||||||
@@ -1368,6 +1380,7 @@
|
@@ -1459,6 +1471,7 @@
|
||||||
myisam-stats-method NULLS_UNEQUAL
|
myisam-stats-method NULLS_UNEQUAL
|
||||||
myisam-use-mmap FALSE
|
myisam-use-mmap FALSE
|
||||||
mysql56-temporal-format TRUE
|
mysql56-temporal-format TRUE
|
||||||
@ -84,16 +84,16 @@
|
|||||||
net-buffer-length 16384
|
net-buffer-length 16384
|
||||||
net-read-timeout 30
|
net-read-timeout 30
|
||||||
net-retry-count 10
|
net-retry-count 10
|
||||||
@@ -1469,6 +1482,8 @@
|
@@ -1561,6 +1574,8 @@
|
||||||
session-track-state-change FALSE
|
session-track-state-change FALSE
|
||||||
session-track-system-variables
|
session-track-system-variables autocommit,character_set_client,character_set_connection,character_set_results,time_zone
|
||||||
session-track-transaction-info OFF
|
session-track-transaction-info OFF
|
||||||
+shared-memory FALSE
|
+shared-memory FALSE
|
||||||
+shared-memory-base-name MYSQL
|
+shared-memory-base-name MYSQL
|
||||||
show-slave-auth-info FALSE
|
show-slave-auth-info FALSE
|
||||||
silent-startup FALSE
|
silent-startup FALSE
|
||||||
skip-grant-tables TRUE
|
skip-grant-tables TRUE
|
||||||
@@ -1493,6 +1508,7 @@
|
@@ -1585,6 +1600,7 @@
|
||||||
slave-type-conversions
|
slave-type-conversions
|
||||||
slow-launch-time 2
|
slow-launch-time 2
|
||||||
slow-query-log FALSE
|
slow-query-log FALSE
|
||||||
@ -101,7 +101,7 @@
|
|||||||
sort-buffer-size 2097152
|
sort-buffer-size 2097152
|
||||||
sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
||||||
stack-trace TRUE
|
stack-trace TRUE
|
||||||
@@ -1506,14 +1522,16 @@
|
@@ -1598,9 +1614,9 @@
|
||||||
sync-relay-log 10000
|
sync-relay-log 10000
|
||||||
sync-relay-log-info 10000
|
sync-relay-log-info 10000
|
||||||
sysdate-is-now FALSE
|
sysdate-is-now FALSE
|
||||||
@ -112,6 +112,8 @@
|
|||||||
+table-open-cache 2000
|
+table-open-cache 2000
|
||||||
table-open-cache-instances 8
|
table-open-cache-instances 8
|
||||||
tc-heuristic-recover OFF
|
tc-heuristic-recover OFF
|
||||||
|
tcp-keepalive-interval 0
|
||||||
|
@@ -1609,6 +1625,8 @@
|
||||||
thread-cache-size 151
|
thread-cache-size 151
|
||||||
thread-pool-idle-timeout 60
|
thread-pool-idle-timeout 60
|
||||||
thread-pool-max-threads 65536
|
thread-pool-max-threads 65536
|
||||||
|
@ -1195,6 +1195,21 @@ The following options may be given as the first argument:
|
|||||||
--tc-heuristic-recover=name
|
--tc-heuristic-recover=name
|
||||||
Decision to use in heuristic recover process. One of: OFF,
|
Decision to use in heuristic recover process. One of: OFF,
|
||||||
COMMIT, ROLLBACK
|
COMMIT, ROLLBACK
|
||||||
|
--tcp-keepalive-interval=#
|
||||||
|
The interval, in seconds, between when successive
|
||||||
|
keep-alive packets are sent if no acknowledgement is
|
||||||
|
received.If set to 0, system dependent default is used.
|
||||||
|
(Automatically configured unless set explicitly)
|
||||||
|
--tcp-keepalive-probes=#
|
||||||
|
The number of unacknowledged probes to send before
|
||||||
|
considering the connection dead and notifying the
|
||||||
|
application layer.If set to 0, system dependent default
|
||||||
|
is used. (Automatically configured unless set explicitly)
|
||||||
|
--tcp-keepalive-time=#
|
||||||
|
Timeout, in milliseconds, with no activity until the
|
||||||
|
first TCP keep-alive packet is sent.If set to 0, system
|
||||||
|
dependent default is used. (Automatically configured
|
||||||
|
unless set explicitly)
|
||||||
--thread-cache-size=#
|
--thread-cache-size=#
|
||||||
How many threads we should keep in a cache for reuse.
|
How many threads we should keep in a cache for reuse.
|
||||||
These are freed after 5 minutes of idle time
|
These are freed after 5 minutes of idle time
|
||||||
@ -1594,6 +1609,9 @@ table-definition-cache 400
|
|||||||
table-open-cache 431
|
table-open-cache 431
|
||||||
table-open-cache-instances 8
|
table-open-cache-instances 8
|
||||||
tc-heuristic-recover OFF
|
tc-heuristic-recover OFF
|
||||||
|
tcp-keepalive-interval 0
|
||||||
|
tcp-keepalive-probes 0
|
||||||
|
tcp-keepalive-time 0
|
||||||
thread-cache-size 151
|
thread-cache-size 151
|
||||||
thread-pool-idle-timeout 60
|
thread-pool-idle-timeout 60
|
||||||
thread-pool-max-threads 65536
|
thread-pool-max-threads 65536
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -220,6 +220,20 @@ NUMERIC_BLOCK_SIZE NULL
|
|||||||
ENUM_VALUE_LIST OFF,ON
|
ENUM_VALUE_LIST OFF,ON
|
||||||
READ_ONLY NO
|
READ_ONLY NO
|
||||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||||
|
VARIABLE_NAME BINLOG_FILE_CACHE_SIZE
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 16384
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 16384
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE BIGINT UNSIGNED
|
||||||
|
VARIABLE_COMMENT The size of file cache for the binary log
|
||||||
|
NUMERIC_MIN_VALUE 8192
|
||||||
|
NUMERIC_MAX_VALUE 18446744073709551615
|
||||||
|
NUMERIC_BLOCK_SIZE 4096
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
VARIABLE_NAME BINLOG_FORMAT
|
VARIABLE_NAME BINLOG_FORMAT
|
||||||
SESSION_VALUE MIXED
|
SESSION_VALUE MIXED
|
||||||
GLOBAL_VALUE MIXED
|
GLOBAL_VALUE MIXED
|
||||||
@ -4112,6 +4126,48 @@ NUMERIC_BLOCK_SIZE 1
|
|||||||
ENUM_VALUE_LIST NULL
|
ENUM_VALUE_LIST NULL
|
||||||
READ_ONLY YES
|
READ_ONLY YES
|
||||||
COMMAND_LINE_ARGUMENT REQUIRED
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_INTERVAL
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT The interval, in seconds, between when successive keep-alive packets are sent if no acknowledgement is received.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_PROBES
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT The number of unacknowledged probes to send before considering the connection dead and notifying the application layer.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_TIME
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT Timeout, in milliseconds, with no activity until the first TCP keep-alive packet is sent.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
VARIABLE_NAME THREAD_CACHE_SIZE
|
VARIABLE_NAME THREAD_CACHE_SIZE
|
||||||
SESSION_VALUE NULL
|
SESSION_VALUE NULL
|
||||||
GLOBAL_VALUE 151
|
GLOBAL_VALUE 151
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4924,6 +4924,48 @@ NUMERIC_BLOCK_SIZE 1
|
|||||||
ENUM_VALUE_LIST NULL
|
ENUM_VALUE_LIST NULL
|
||||||
READ_ONLY YES
|
READ_ONLY YES
|
||||||
COMMAND_LINE_ARGUMENT REQUIRED
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_INTERVAL
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT The interval, in seconds, between when successive keep-alive packets are sent if no acknowledgement is received.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_PROBES
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT The number of unacknowledged probes to send before considering the connection dead and notifying the application layer.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
|
VARIABLE_NAME TCP_KEEPALIVE_TIME
|
||||||
|
SESSION_VALUE NULL
|
||||||
|
GLOBAL_VALUE 0
|
||||||
|
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||||
|
DEFAULT_VALUE 0
|
||||||
|
VARIABLE_SCOPE GLOBAL
|
||||||
|
VARIABLE_TYPE INT
|
||||||
|
VARIABLE_COMMENT Timeout, in milliseconds, with no activity until the first TCP keep-alive packet is sent.If set to 0, system dependent default is used.
|
||||||
|
NUMERIC_MIN_VALUE 0
|
||||||
|
NUMERIC_MAX_VALUE 2147483
|
||||||
|
NUMERIC_BLOCK_SIZE 1
|
||||||
|
ENUM_VALUE_LIST NULL
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT REQUIRED
|
||||||
VARIABLE_NAME THREAD_CACHE_SIZE
|
VARIABLE_NAME THREAD_CACHE_SIZE
|
||||||
SESSION_VALUE NULL
|
SESSION_VALUE NULL
|
||||||
GLOBAL_VALUE 151
|
GLOBAL_VALUE 151
|
||||||
|
9
mysql-test/suite/sys_vars/r/tcp_keepalive_time.result
Normal file
9
mysql-test/suite/sys_vars/r/tcp_keepalive_time.result
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
set global tcp_keepalive_time = 1;
|
||||||
|
set global tcp_keepalive_interval =1;
|
||||||
|
set global tcp_keepalive_probes=1;
|
||||||
|
connect con1,"127.0.0.1",root,,test,$MASTER_MYPORT,;
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
set global tcp_keepalive_time= default;
|
||||||
|
set global tcp_keepalive_interval= default;
|
||||||
|
set global tcp_keepalive_probes=default;
|
11
mysql-test/suite/sys_vars/t/tcp_keepalive_time.test
Normal file
11
mysql-test/suite/sys_vars/t/tcp_keepalive_time.test
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--source include/not_embedded.inc
|
||||||
|
# A smoke test for TCP keepalive options
|
||||||
|
set global tcp_keepalive_time = 1;
|
||||||
|
set global tcp_keepalive_interval =1;
|
||||||
|
set global tcp_keepalive_probes=1;
|
||||||
|
connect(con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
set global tcp_keepalive_time= default;
|
||||||
|
set global tcp_keepalive_interval= default;
|
||||||
|
set global tcp_keepalive_probes=default;
|
@ -45,6 +45,7 @@ HASH global_index_stats;
|
|||||||
extern mysql_mutex_t LOCK_global_user_client_stats;
|
extern mysql_mutex_t LOCK_global_user_client_stats;
|
||||||
extern mysql_mutex_t LOCK_global_table_stats;
|
extern mysql_mutex_t LOCK_global_table_stats;
|
||||||
extern mysql_mutex_t LOCK_global_index_stats;
|
extern mysql_mutex_t LOCK_global_index_stats;
|
||||||
|
extern vio_keepalive_opts opt_vio_keepalive;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get structure for logging connection data for the current user
|
Get structure for logging connection data for the current user
|
||||||
@ -1064,6 +1065,7 @@ static int check_connection(THD *thd)
|
|||||||
bzero((char*) &net->vio->remote, sizeof(net->vio->remote));
|
bzero((char*) &net->vio->remote, sizeof(net->vio->remote));
|
||||||
}
|
}
|
||||||
vio_keepalive(net->vio, TRUE);
|
vio_keepalive(net->vio, TRUE);
|
||||||
|
vio_set_keepalive_options(net->vio, &opt_vio_keepalive);
|
||||||
|
|
||||||
if (thd->packet.alloc(thd->variables.net_buffer_length))
|
if (thd->packet.alloc(thd->variables.net_buffer_length))
|
||||||
{
|
{
|
||||||
|
@ -5311,6 +5311,38 @@ static Sys_var_ulong Sys_host_cache_size(
|
|||||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
|
||||||
ON_UPDATE(fix_host_cache_size));
|
ON_UPDATE(fix_host_cache_size));
|
||||||
|
|
||||||
|
vio_keepalive_opts opt_vio_keepalive;
|
||||||
|
|
||||||
|
static Sys_var_int Sys_keepalive_time(
|
||||||
|
"tcp_keepalive_time",
|
||||||
|
"Timeout, in milliseconds, with no activity until the first TCP keep-alive packet is sent."
|
||||||
|
"If set to 0, system dependent default is used.",
|
||||||
|
AUTO_SET GLOBAL_VAR(opt_vio_keepalive.idle),
|
||||||
|
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000),
|
||||||
|
DEFAULT(0),
|
||||||
|
BLOCK_SIZE(1),
|
||||||
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL));
|
||||||
|
|
||||||
|
static Sys_var_int Sys_keepalive_interval(
|
||||||
|
"tcp_keepalive_interval",
|
||||||
|
"The interval, in seconds, between when successive keep-alive packets are sent if no acknowledgement is received."
|
||||||
|
"If set to 0, system dependent default is used.",
|
||||||
|
AUTO_SET GLOBAL_VAR(opt_vio_keepalive.interval),
|
||||||
|
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000),
|
||||||
|
DEFAULT(0),
|
||||||
|
BLOCK_SIZE(1),
|
||||||
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL));
|
||||||
|
|
||||||
|
static Sys_var_int Sys_keepalive_probes(
|
||||||
|
"tcp_keepalive_probes",
|
||||||
|
"The number of unacknowledged probes to send before considering the connection dead and notifying the application layer."
|
||||||
|
"If set to 0, system dependent default is used.",
|
||||||
|
AUTO_SET GLOBAL_VAR(opt_vio_keepalive.probes),
|
||||||
|
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000),
|
||||||
|
DEFAULT(0),
|
||||||
|
BLOCK_SIZE(1),
|
||||||
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL));
|
||||||
|
|
||||||
static Sys_var_charptr Sys_ignore_db_dirs(
|
static Sys_var_charptr Sys_ignore_db_dirs(
|
||||||
"ignore_db_dirs",
|
"ignore_db_dirs",
|
||||||
"Specifies a directory to add to the ignore list when collecting "
|
"Specifies a directory to add to the ignore list when collecting "
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <MSWSock.h>
|
#include <MSWSock.h>
|
||||||
|
#include <mstcpip.h>
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
#endif
|
#endif
|
||||||
#include "my_context.h"
|
#include "my_context.h"
|
||||||
@ -522,6 +523,63 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
|
|||||||
DBUG_RETURN(r);
|
DBUG_RETURN(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set socket options for keepalive e.g., TCP_KEEPCNT, TCP_KEEPIDLE/TCP_KEEPALIVE, TCP_KEEPINTVL
|
||||||
|
*/
|
||||||
|
int vio_set_keepalive_options(Vio* vio, const struct vio_keepalive_opts *opts)
|
||||||
|
{
|
||||||
|
#if defined _WIN32
|
||||||
|
struct tcp_keepalive s;
|
||||||
|
DWORD nbytes;
|
||||||
|
|
||||||
|
if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SHARED_MEMORY)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!opts->idle && !opts->interval)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
s.onoff= 1;
|
||||||
|
s.keepalivetime= opts->idle? opts->idle * 1000 : 7200;
|
||||||
|
s.keepaliveinterval= opts->interval?opts->interval * 1000 : 1;
|
||||||
|
|
||||||
|
return WSAIoctl(vio->mysql_socket.fd, SIO_KEEPALIVE_VALS, (LPVOID) &s, sizeof(s),
|
||||||
|
NULL, 0, &nbytes, NULL, NULL);
|
||||||
|
|
||||||
|
#elif defined (TCP_KEEPIDLE) || defined (TCP_KEEPALIVE)
|
||||||
|
|
||||||
|
int ret= 0;
|
||||||
|
if (opts->idle)
|
||||||
|
{
|
||||||
|
#ifdef TCP_KEEPIDLE // Linux only
|
||||||
|
ret= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_KEEPIDLE, (char *)&opts->idle, sizeof(opts->idle));
|
||||||
|
#elif defined (TCP_KEEPALIVE)
|
||||||
|
ret= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_KEEPALIVE, (char *)&opts->idle, sizeof(opts->idle));
|
||||||
|
#endif
|
||||||
|
if(ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TCP_KEEPCNT // Linux only
|
||||||
|
if(opts->probes)
|
||||||
|
{
|
||||||
|
ret= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_KEEPCNT, (char *)&opts->probes, sizeof(opts->probes));
|
||||||
|
if(ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TCP_KEEPINTVL // Linux only
|
||||||
|
if(opts->interval)
|
||||||
|
{
|
||||||
|
ret= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_KEEPINTVL, (char *)&opts->interval, sizeof(opts->interval));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
#else /*TCP_KEEPIDLE || TCP_KEEPALIVE */
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicate whether a I/O operation must be retried later.
|
Indicate whether a I/O operation must be retried later.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user