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
b1fabf6c
Commit
b1fabf6c
authored
Apr 28, 2020
by
Monty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Performance improvements to test if WSREP if active
parent
93281221
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
56 deletions
+81
-56
sql/sql_parse.cc
sql/sql_parse.cc
+59
-40
sql/wsrep_mysqld.cc
sql/wsrep_mysqld.cc
+21
-16
sql/wsrep_mysqld.h
sql/wsrep_mysqld.h
+1
-0
No files found.
sql/sql_parse.cc
View file @
b1fabf6c
...
@@ -1291,7 +1291,7 @@ bool do_command(THD *thd)
...
@@ -1291,7 +1291,7 @@ bool do_command(THD *thd)
Aborted by background rollbacker thread.
Aborted by background rollbacker thread.
Handle error here and jump straight to out
Handle error here and jump straight to out
*/
*/
if
(
wsrep_before_command
(
thd
))
if
(
unlikely
(
wsrep_service_started
)
&&
wsrep_before_command
(
thd
))
{
{
thd
->
store_globals
();
thd
->
store_globals
();
WSREP_LOG_THD
(
thd
,
"enter found BF aborted"
);
WSREP_LOG_THD
(
thd
,
"enter found BF aborted"
);
...
@@ -1368,7 +1368,8 @@ bool do_command(THD *thd)
...
@@ -1368,7 +1368,8 @@ bool do_command(THD *thd)
if
(
packet_length
!=
packet_error
)
if
(
packet_length
!=
packet_error
)
{
{
/* there was a command to process, and before_command() has been called */
/* there was a command to process, and before_command() has been called */
wsrep_after_command_after_result
(
thd
);
if
(
unlikely
(
wsrep_service_started
))
wsrep_after_command_after_result
(
thd
);
}
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
DBUG_RETURN
(
return_value
);
DBUG_RETURN
(
return_value
);
...
@@ -1659,14 +1660,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1659,14 +1660,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{
{
thd
->
status_var
.
com_other
++
;
thd
->
status_var
.
com_other
++
;
#ifdef WITH_WSREP
#ifdef WITH_WSREP
wsrep_after_command_ignore_result
(
thd
);
if
(
unlikely
(
wsrep_service_started
))
wsrep_close
(
thd
);
{
wsrep_after_command_ignore_result
(
thd
);
wsrep_close
(
thd
);
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
thd
->
change_user
();
thd
->
change_user
();
thd
->
clear_error
();
// if errors from rollback
thd
->
clear_error
();
// if errors from rollback
#ifdef WITH_WSREP
#ifdef WITH_WSREP
wsrep_open
(
thd
);
if
(
unlikely
(
wsrep_service_started
))
wsrep_before_command
(
thd
);
{
wsrep_open
(
thd
);
wsrep_before_command
(
thd
);
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
/* Restore original charset from client authentication packet.*/
/* Restore original charset from client authentication packet.*/
if
(
thd
->
org_charset
)
if
(
thd
->
org_charset
)
...
@@ -1680,13 +1687,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1680,13 +1687,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
status_var_increment
(
thd
->
status_var
.
com_other
);
status_var_increment
(
thd
->
status_var
.
com_other
);
#ifdef WITH_WSREP
#ifdef WITH_WSREP
wsrep_after_command_ignore_result
(
thd
);
if
(
unlikely
(
wsrep_service_started
))
wsrep_close
(
thd
);
{
wsrep_after_command_ignore_result
(
thd
);
wsrep_close
(
thd
);
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
thd
->
change_user
();
thd
->
change_user
();
#ifdef WITH_WSREP
#ifdef WITH_WSREP
wsrep_open
(
thd
);
if
(
unlikely
(
wsrep_service_started
))
wsrep_before_command
(
thd
);
{
wsrep_open
(
thd
);
wsrep_before_command
(
thd
);
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
thd
->
clear_error
();
// if errors from rollback
thd
->
clear_error
();
// if errors from rollback
...
@@ -2376,46 +2389,52 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -2376,46 +2389,52 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
}
dispatch_end:
dispatch_end:
do_end_of_statement
=
true
;
#ifdef WITH_WSREP
#ifdef WITH_WSREP
/*
/*
BF aborted before sending response back to client
Next test should really be WSREP(thd), but that causes a failure when doing
'set WSREP_ON=0'
*/
*/
if
(
thd
->
killed
==
KILL_QUERY
)
if
(
unlikely
(
wsrep_service_started
))
{
WSREP_DEBUG
(
"THD is killed at dispatch_end"
);
}
wsrep_after_command_before_result
(
thd
);
if
(
wsrep_current_error
(
thd
)
&&
!
(
command
==
COM_STMT_PREPARE
||
command
==
COM_STMT_FETCH
||
command
==
COM_STMT_SEND_LONG_DATA
||
command
==
COM_STMT_CLOSE
))
{
/* todo: Pass wsrep client state current error to override */
wsrep_override_error
(
thd
,
wsrep_current_error
(
thd
),
wsrep_current_error_status
(
thd
));
WSREP_LOG_THD
(
thd
,
"leave"
);
}
if
(
WSREP
(
thd
))
{
{
/*
/*
MDEV-10812
BF aborted before sending response back to client
In the case of COM_QUIT/COM_STMT_CLOSE thread status should be disabled.
*/
*/
DBUG_ASSERT
((
command
!=
COM_QUIT
&&
command
!=
COM_STMT_CLOSE
)
if
(
thd
->
killed
==
KILL_QUERY
)
{
WSREP_DEBUG
(
"THD is killed at dispatch_end"
);
}
wsrep_after_command_before_result
(
thd
);
if
(
wsrep_current_error
(
thd
)
&&
!
(
command
==
COM_STMT_PREPARE
||
command
==
COM_STMT_FETCH
||
command
==
COM_STMT_SEND_LONG_DATA
||
command
==
COM_STMT_CLOSE
))
{
/* todo: Pass wsrep client state current error to override */
wsrep_override_error
(
thd
,
wsrep_current_error
(
thd
),
wsrep_current_error_status
(
thd
));
WSREP_LOG_THD
(
thd
,
"leave"
);
}
if
(
WSREP
(
thd
))
{
/*
MDEV-10812
In the case of COM_QUIT/COM_STMT_CLOSE thread status should be disabled.
*/
DBUG_ASSERT
((
command
!=
COM_QUIT
&&
command
!=
COM_STMT_CLOSE
)
||
thd
->
get_stmt_da
()
->
is_disabled
());
||
thd
->
get_stmt_da
()
->
is_disabled
());
DBUG_ASSERT
(
thd
->
wsrep_trx
().
state
()
!=
wsrep
::
transaction
::
s_replaying
);
DBUG_ASSERT
(
thd
->
wsrep_trx
().
state
()
!=
wsrep
::
transaction
::
s_replaying
);
/* wsrep BF abort in query exec phase */
/* wsrep BF abort in query exec phase */
mysql_mutex_lock
(
&
thd
->
LOCK_thd_kill
);
mysql_mutex_lock
(
&
thd
->
LOCK_thd_kill
);
do_end_of_statement
=
thd_is_connection_alive
(
thd
);
do_end_of_statement
=
thd_is_connection_alive
(
thd
);
mysql_mutex_unlock
(
&
thd
->
LOCK_thd_kill
);
mysql_mutex_unlock
(
&
thd
->
LOCK_thd_kill
);
}
}
}
else
do_end_of_statement
=
true
;
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
if
(
do_end_of_statement
)
if
(
do_end_of_statement
)
{
{
DBUG_ASSERT
(
thd
->
derived_tables
==
NULL
&&
DBUG_ASSERT
(
thd
->
derived_tables
==
NULL
&&
...
...
sql/wsrep_mysqld.cc
View file @
b1fabf6c
...
@@ -99,6 +99,7 @@ my_bool wsrep_desync; // De(re)synchronize the node fr
...
@@ -99,6 +99,7 @@ my_bool wsrep_desync; // De(re)synchronize the node fr
my_bool
wsrep_strict_ddl
;
// Reject DDL to
my_bool
wsrep_strict_ddl
;
// Reject DDL to
// effected tables not
// effected tables not
// supporting Galera replication
// supporting Galera replication
bool
wsrep_service_started
;
// If Galera was initialized
long
wsrep_slave_threads
;
// No. of slave appliers threads
long
wsrep_slave_threads
;
// No. of slave appliers threads
ulong
wsrep_retry_autocommit
;
// Retry aborted autocommit trx
ulong
wsrep_retry_autocommit
;
// Retry aborted autocommit trx
ulong
wsrep_max_ws_size
;
// Max allowed ws (RBR buffer) size
ulong
wsrep_max_ws_size
;
// Max allowed ws (RBR buffer) size
...
@@ -831,10 +832,6 @@ int wsrep_init()
...
@@ -831,10 +832,6 @@ int wsrep_init()
return
err
;
return
err
;
}
}
global_system_variables
.
wsrep_on
=
1
;
WSREP_ON_
=
wsrep_provider
&&
strcmp
(
wsrep_provider
,
WSREP_NONE
);
if
(
wsrep_gtid_mode
&&
opt_bin_log
&&
!
opt_log_slave_updates
)
if
(
wsrep_gtid_mode
&&
opt_bin_log
&&
!
opt_log_slave_updates
)
{
{
WSREP_ERROR
(
"Option --log-slave-updates is required if "
WSREP_ERROR
(
"Option --log-slave-updates is required if "
...
@@ -866,6 +863,11 @@ int wsrep_init()
...
@@ -866,6 +863,11 @@ int wsrep_init()
return
1
;
return
1
;
}
}
/* Now WSREP is fully initialized */
global_system_variables
.
wsrep_on
=
1
;
WSREP_ON_
=
wsrep_provider
&&
strcmp
(
wsrep_provider
,
WSREP_NONE
);
wsrep_service_started
=
1
;
wsrep_init_provider_status_variables
();
wsrep_init_provider_status_variables
();
wsrep_capabilities_export
(
Wsrep_server_state
::
instance
().
provider
().
capabilities
(),
wsrep_capabilities_export
(
Wsrep_server_state
::
instance
().
provider
().
capabilities
(),
&
wsrep_provider_capabilities
);
&
wsrep_provider_capabilities
);
...
@@ -1162,18 +1164,21 @@ bool wsrep_start_replication()
...
@@ -1162,18 +1164,21 @@ bool wsrep_start_replication()
bool
wsrep_must_sync_wait
(
THD
*
thd
,
uint
mask
)
bool
wsrep_must_sync_wait
(
THD
*
thd
,
uint
mask
)
{
{
bool
ret
;
bool
ret
=
0
;
mysql_mutex_lock
(
&
thd
->
LOCK_thd_data
);
if
(
thd
->
variables
.
wsrep_on
)
ret
=
(
thd
->
variables
.
wsrep_sync_wait
&
mask
)
&&
{
thd
->
wsrep_client_thread
&&
mysql_mutex_lock
(
&
thd
->
LOCK_thd_data
);
thd
->
variables
.
wsrep_on
&&
ret
=
(
thd
->
variables
.
wsrep_sync_wait
&
mask
)
&&
!
(
thd
->
variables
.
wsrep_dirty_reads
&&
thd
->
wsrep_client_thread
&&
!
is_update_query
(
thd
->
lex
->
sql_command
))
&&
thd
->
variables
.
wsrep_on
&&
!
thd
->
in_active_multi_stmt_transaction
()
&&
!
(
thd
->
variables
.
wsrep_dirty_reads
&&
thd
->
wsrep_trx
().
state
()
!=
!
is_update_query
(
thd
->
lex
->
sql_command
))
&&
wsrep
::
transaction
::
s_replaying
&&
!
thd
->
in_active_multi_stmt_transaction
()
&&
thd
->
wsrep_cs
().
sync_wait_gtid
().
is_undefined
();
thd
->
wsrep_trx
().
state
()
!=
mysql_mutex_unlock
(
&
thd
->
LOCK_thd_data
);
wsrep
::
transaction
::
s_replaying
&&
thd
->
wsrep_cs
().
sync_wait_gtid
().
is_undefined
();
mysql_mutex_unlock
(
&
thd
->
LOCK_thd_data
);
}
return
ret
;
return
ret
;
}
}
...
...
sql/wsrep_mysqld.h
View file @
b1fabf6c
...
@@ -186,6 +186,7 @@ void wsrep_recover_sr_from_storage(THD *);
...
@@ -186,6 +186,7 @@ void wsrep_recover_sr_from_storage(THD *);
// Other wsrep global variables
// Other wsrep global variables
extern
my_bool
wsrep_inited
;
// whether wsrep is initialized ?
extern
my_bool
wsrep_inited
;
// whether wsrep is initialized ?
extern
bool
wsrep_service_started
;
extern
"C"
void
wsrep_fire_rollbacker
(
THD
*
thd
);
extern
"C"
void
wsrep_fire_rollbacker
(
THD
*
thd
);
extern
"C"
uint32
wsrep_thd_wsrep_rand
(
THD
*
thd
);
extern
"C"
uint32
wsrep_thd_wsrep_rand
(
THD
*
thd
);
...
...
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