Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ce30c994
Commit
ce30c994
authored
May 17, 2019
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved vio allocation to connection thread
Part of MDEV-19515 - Improve connect speed
parent
efb61c12
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
56 deletions
+58
-56
sql/handle_connections_win.cc
sql/handle_connections_win.cc
+3
-5
sql/mysqld.cc
sql/mysqld.cc
+9
-24
sql/sql_connect.cc
sql/sql_connect.cc
+25
-10
sql/sql_connect.h
sql/sql_connect.h
+14
-8
sql/threadpool_generic.cc
sql/threadpool_generic.cc
+4
-5
sql/threadpool_win.cc
sql/threadpool_win.cc
+3
-4
No files found.
sql/handle_connections_win.cc
View file @
ce30c994
...
...
@@ -367,16 +367,14 @@ struct Pipe_Listener : public Listener
static
void
create_pipe_connection
(
HANDLE
pipe
)
{
CONNECT
*
connect
;
if
(
!
(
connect
=
new
CONNECT
)
||
!
(
connect
->
vio
=
vio_new_win32pipe
(
pipe
)))
if
(
auto
connect
=
new
CONNECT
(
pipe
))
create_new_thread
(
connect
);
else
{
CloseHandle
(
pipe
);
delete
connect
;
statistic_increment
(
aborted_connects
,
&
LOCK_status
);
statistic_increment
(
connection_errors_internal
,
&
LOCK_status
);
return
;
}
create_new_thread
(
connect
);
}
/* Threadpool callback.*/
...
...
sql/mysqld.cc
View file @
ce30c994
...
...
@@ -6293,8 +6293,6 @@ void create_new_thread(CONNECT *connect)
void
handle_accepted_socket
(
MYSQL_SOCKET
new_sock
,
MYSQL_SOCKET
sock
)
{
CONNECT
*
connect
;
#ifdef HAVE_LIBWRAP
{
if
(
mysql_socket_getfd
(
sock
)
==
mysql_socket_getfd
(
base_ip_sock
)
||
...
...
@@ -6340,34 +6338,21 @@ void handle_accepted_socket(MYSQL_SOCKET new_sock, MYSQL_SOCKET sock)
DBUG_PRINT
(
"info"
,
(
"Creating CONNECT for new connection"
));
if
((
connect
=
new
CONNECT
()))
{
bool
is_unix_sock
=
mysql_socket_getfd
(
sock
)
==
mysql_socket_getfd
(
unix_sock
);
if
(
!
(
connect
->
vio
=
mysql_socket_vio_new
(
new_sock
,
is_unix_sock
?
VIO_TYPE_SOCKET
:
VIO_TYPE_TCPIP
,
is_unix_sock
?
VIO_LOCALHOST
:
0
)))
{
delete
connect
;
connect
=
0
;
// Error handling below
}
}
if
(
!
connect
)
if
(
auto
connect
=
new
CONNECT
(
new_sock
,
mysql_socket_getfd
(
sock
)
==
mysql_socket_getfd
(
unix_sock
)
?
VIO_TYPE_SOCKET
:
VIO_TYPE_TCPIP
,
mysql_socket_getfd
(
sock
)
==
mysql_socket_getfd
(
extra_ip_sock
)
?
extra_thread_scheduler
:
thread_scheduler
))
create_new_thread
(
connect
);
else
{
/* Connect failure */
(
void
)
mysql_socket_close
(
new_sock
);
statistic_increment
(
aborted_connects
,
&
LOCK_status
);
statistic_increment
(
connection_errors_internal
,
&
LOCK_status
);
return
;
}
if
(
mysql_socket_getfd
(
sock
)
==
mysql_socket_getfd
(
extra_ip_sock
))
connect
->
scheduler
=
extra_thread_scheduler
;
create_new_thread
(
connect
);
}
#ifndef _WIN32
...
...
sql/sql_connect.cc
View file @
ce30c994
...
...
@@ -1441,8 +1441,15 @@ void CONNECT::close_and_delete()
{
DBUG_ENTER
(
"close_and_delete"
);
if
(
vio
)
vio_close
(
vio
);
#if _WIN32
if
(
vio_type
==
VIO_TYPE_NAMEDPIPE
)
CloseHandle
(
pipe
);
else
#endif
if
(
vio_type
!=
VIO_CLOSED
)
mysql_socket_close
(
sock
);
vio_type
=
VIO_CLOSED
;
if
(
thread_count_incremented
)
dec_connection_count
(
scheduler
);
statistic_increment
(
connection_errors_internal
,
&
LOCK_status
);
...
...
@@ -1473,18 +1480,12 @@ void CONNECT::close_with_error(uint sql_errno,
}
CONNECT
::~
CONNECT
()
{
if
(
vio
)
vio_delete
(
vio
);
}
/* Reuse or create a THD based on a CONNECT object */
THD
*
CONNECT
::
create_thd
(
THD
*
thd
)
{
bool
res
,
thd_reused
=
thd
!=
0
;
Vio
*
vio
;
DBUG_ENTER
(
"create_thd"
);
DBUG_EXECUTE_IF
(
"simulate_failed_connection_2"
,
DBUG_RETURN
(
0
);
);
...
...
@@ -1503,9 +1504,23 @@ THD *CONNECT::create_thd(THD *thd)
else
if
(
!
(
thd
=
new
THD
(
thread_id
)))
DBUG_RETURN
(
0
);
#if _WIN32
if
(
vio_type
==
VIO_TYPE_NAMEDPIPE
)
vio
=
vio_new_win32pipe
(
pipe
);
else
#endif
vio
=
mysql_socket_vio_new
(
sock
,
vio_type
,
vio_type
==
VIO_TYPE_SOCKET
?
VIO_LOCALHOST
:
0
);
if
(
!
vio
)
{
if
(
!
thd_reused
)
delete
thd
;
DBUG_RETURN
(
0
);
}
set_current_thd
(
thd
);
res
=
my_net_init
(
&
thd
->
net
,
vio
,
thd
,
MYF
(
MY_THREAD_SPECIFIC
));
vio
=
0
;
// Vio now handled by thd
vio
_type
=
VIO_CLOSED
;
// Vio now handled by thd
if
(
unlikely
(
res
||
thd
->
is_error
()))
{
...
...
sql/sql_connect.h
View file @
ce30c994
...
...
@@ -21,6 +21,7 @@
#include "structs.h"
#include <mysql/psi/mysql_socket.h>
#include <hash.h>
#include "violite.h"
/*
Object to hold connect information to be given to the newly created thread
...
...
@@ -30,8 +31,14 @@ struct scheduler_functions;
class
CONNECT
:
public
ilink
{
public:
/* To be copied to THD */
Vio
*
vio
;
/* Copied to THD with my_net_init() */
MYSQL_SOCKET
sock
;
#ifdef _WIN32
HANDLE
pipe
;
CONNECT
(
HANDLE
pipe_arg
)
:
pipe
(
pipe_arg
),
vio_type
(
VIO_TYPE_NAMEDPIPE
),
scheduler
(
thread_scheduler
),
thread_id
(
0
),
thread_count_incremented
(
0
),
prior_thr_create_utime
(
0
)
{}
#endif
enum
enum_vio_type
vio_type
;
scheduler_functions
*
scheduler
;
my_thread_id
thread_id
;
...
...
@@ -39,12 +46,11 @@ class CONNECT : public ilink {
bool
thread_count_incremented
;
ulonglong
prior_thr_create_utime
;
CONNECT
()
:
vio
(
0
),
scheduler
(
thread_scheduler
),
thread_id
(
0
),
thread_count_incremented
(
0
),
prior_thr_create_utime
(
0
)
{
};
~
CONNECT
();
CONNECT
(
MYSQL_SOCKET
sock_arg
,
enum
enum_vio_type
vio_type_arg
,
scheduler_functions
*
scheduler_arg
)
:
sock
(
sock_arg
),
vio_type
(
vio_type_arg
),
scheduler
(
scheduler_arg
),
thread_id
(
0
),
thread_count_incremented
(
0
),
prior_thr_create_utime
(
0
)
{}
~
CONNECT
()
{
DBUG_ASSERT
(
vio_type
==
VIO_CLOSED
);
}
void
close_and_delete
();
void
close_with_error
(
uint
sql_errno
,
const
char
*
message
,
uint
close_error
);
...
...
sql/threadpool_generic.cc
View file @
ce30c994
...
...
@@ -1433,14 +1433,13 @@ TP_connection_generic::TP_connection_generic(CONNECT *c):
,
overlapped
()
#endif
{
DBUG_ASSERT
(
c
->
vio
);
DBUG_ASSERT
(
c
->
vio
_type
!=
VIO_CLOSED
);
#ifdef _WIN32
vio_type
=
c
->
vio
->
type
;
fd
=
(
vio_type
==
VIO_TYPE_NAMEDPIPE
)
?
c
->
vio
->
hPipe
:
(
TP_file_handle
)
mysql_socket_getfd
(
c
->
vio
->
mysql_socket
);
fd
=
(
c
->
vio_type
==
VIO_TYPE_NAMEDPIPE
)
?
c
->
pipe
:
(
TP_file_handle
)
mysql_socket_getfd
(
c
->
sock
);
#else
fd
=
mysql_socket_getfd
(
c
->
vio
->
mysql_socket
);
fd
=
mysql_socket_getfd
(
c
->
sock
);
#endif
/* Assign connection to a group. */
...
...
sql/threadpool_win.cc
View file @
ce30c994
...
...
@@ -167,15 +167,14 @@ int TP_connection_win::init()
{
memset
(
&
overlapped
,
0
,
sizeof
(
OVERLAPPED
));
Vio
*
vio
=
connect
->
vio
;
switch
((
vio_type
=
vio
->
type
))
switch
((
vio_type
=
connect
->
vio_type
))
{
case
VIO_TYPE_SSL
:
case
VIO_TYPE_TCPIP
:
handle
=
(
HANDLE
)
mysql_socket_getfd
(
vio
->
mysql_socket
);
handle
=
(
HANDLE
)
mysql_socket_getfd
(
connect
->
sock
);
break
;
case
VIO_TYPE_NAMEDPIPE
:
handle
=
(
HANDLE
)
vio
->
hP
ipe
;
handle
=
connect
->
p
ipe
;
break
;
default:
abort
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment