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
355bf4fb
Commit
355bf4fb
authored
Jul 30, 2016
by
Nirbhay Choubey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup around wsrep mdl exception.
parent
fb076581
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
58 deletions
+98
-58
sql/mdl.cc
sql/mdl.cc
+47
-27
sql/wsrep_mysqld.cc
sql/wsrep_mysqld.cc
+51
-31
No files found.
sql/mdl.cc
View file @
355bf4fb
...
@@ -2929,34 +2929,54 @@ bool MDL_context::has_explicit_locks()
...
@@ -2929,34 +2929,54 @@ bool MDL_context::has_explicit_locks()
}
}
#ifdef WITH_WSREP
#ifdef WITH_WSREP
void
MDL_ticket
::
wsrep_report
(
bool
debug
)
static
const
char
*
wsrep_get_mdl_type_name
(
enum_mdl_type
type
)
{
{
if
(
debug
)
switch
(
type
)
{
{
const
PSI_stage_info
*
psi_stage
=
m_lock
->
key
.
get_wait_state_name
();
case
MDL_INTENTION_EXCLUSIVE
:
return
"intention exclusive"
;
case
MDL_SHARED
:
return
"shared"
;
WSREP_DEBUG
(
"MDL ticket: type: %s space: %s db: %s name: %s (%s)"
,
case
MDL_SHARED_HIGH_PRIO
:
return
"shared high prio"
;
(
get_type
()
==
MDL_INTENTION_EXCLUSIVE
)
?
"intention exclusive"
:
case
MDL_SHARED_READ
:
return
"shared read"
;
((
get_type
()
==
MDL_SHARED
)
?
"shared"
:
case
MDL_SHARED_WRITE
:
return
"shared write"
;
((
get_type
()
==
MDL_SHARED_HIGH_PRIO
?
"shared high prio"
:
case
MDL_SHARED_UPGRADABLE
:
return
"shared upgradable"
;
((
get_type
()
==
MDL_SHARED_READ
)
?
"shared read"
:
case
MDL_SHARED_NO_WRITE
:
return
"shared no write"
;
((
get_type
()
==
MDL_SHARED_WRITE
)
?
"shared write"
:
case
MDL_SHARED_NO_READ_WRITE
:
return
"shared no read write"
;
((
get_type
()
==
MDL_SHARED_NO_WRITE
)
?
"shared no write"
:
case
MDL_EXCLUSIVE
:
return
"exclusive"
;
((
get_type
()
==
MDL_SHARED_NO_READ_WRITE
)
?
"shared no read write"
:
default:
break
;
((
get_type
()
==
MDL_EXCLUSIVE
)
?
"exclusive"
:
}
"UNKNOWN"
)))))))),
return
"UNKNOWN"
;
(
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
GLOBAL
)
?
"GLOBAL"
:
}
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
SCHEMA
)
?
"SCHEMA"
:
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
TABLE
)
?
"TABLE"
:
static
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
TABLE
)
?
"FUNCTION"
:
const
char
*
wsrep_get_mdl_namespace_name
(
MDL_key
::
enum_mdl_namespace
ns
)
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
TABLE
)
?
"PROCEDURE"
:
{
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
TABLE
)
?
"TRIGGER"
:
switch
(
ns
)
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
TABLE
)
?
"EVENT"
:
{
((
m_lock
->
key
.
mdl_namespace
()
==
MDL_key
::
COMMIT
)
?
"COMMIT"
:
case
MDL_key
:
:
GLOBAL
:
return
"GLOBAL"
;
(
char
*
)
"UNKNOWN"
))))))),
case
MDL_key
:
:
SCHEMA
:
return
"SCHEMA"
;
m_lock
->
key
.
db_name
(),
case
MDL_key
:
:
TABLE
:
return
"TABLE"
;
m_lock
->
key
.
name
(),
case
MDL_key
:
:
FUNCTION
:
return
"FUNCTION"
;
psi_stage
->
m_name
);
case
MDL_key
:
:
PROCEDURE
:
return
"PROCEDURE"
;
}
case
MDL_key
:
:
TRIGGER
:
return
"TRIGGER"
;
case
MDL_key
:
:
EVENT
:
return
"EVENT"
;
case
MDL_key
:
:
COMMIT
:
return
"COMMIT"
;
case
MDL_key
:
:
USER_LOCK
:
return
"USER_LOCK"
;
default:
break
;
}
return
"UNKNOWN"
;
}
void
MDL_ticket
::
wsrep_report
(
bool
debug
)
{
if
(
!
debug
)
return
;
const
PSI_stage_info
*
psi_stage
=
m_lock
->
key
.
get_wait_state_name
();
WSREP_DEBUG
(
"MDL ticket: type: %s space: %s db: %s name: %s (%s)"
,
wsrep_get_mdl_type_name
(
get_type
()),
wsrep_get_mdl_namespace_name
(
m_lock
->
key
.
mdl_namespace
()),
m_lock
->
key
.
db_name
(),
m_lock
->
key
.
name
(),
psi_stage
->
m_name
);
}
}
#endif
/* WITH_WSREP */
#endif
/* WITH_WSREP */
sql/wsrep_mysqld.cc
View file @
355bf4fb
...
@@ -1684,22 +1684,41 @@ void wsrep_to_isolation_end(THD *thd)
...
@@ -1684,22 +1684,41 @@ void wsrep_to_isolation_end(THD *thd)
@retval FALSE Lock request cannot be granted
@retval FALSE Lock request cannot be granted
*/
*/
bool
bool
wsrep_grant_mdl_exception
(
MDL_context
*
requestor_ctx
,
wsrep_grant_mdl_exception
(
MDL_context
*
requestor_ctx
,
MDL_ticket
*
ticket
,
MDL_ticket
*
ticket
,
const
MDL_key
*
key
)
const
MDL_key
*
key
{
)
{
/* Fallback to the non-wsrep behaviour */
/* Fallback to the non-wsrep behaviour */
if
(
!
WSREP_ON
)
return
FALSE
;
if
(
!
WSREP_ON
)
return
FALSE
;
THD
*
request_thd
=
requestor_ctx
->
get_thd
();
THD
*
request_thd
=
requestor_ctx
->
get_thd
();
THD
*
granted_thd
=
ticket
->
get_ctx
()
->
get_thd
();
THD
*
granted_thd
=
ticket
->
get_ctx
()
->
get_thd
();
bool
ret
=
FALSE
;
bool
ret
=
false
;
const
char
*
schema
=
key
->
db_name
();
const
char
*
schema
=
key
->
db_name
();
int
schema_len
=
key
->
db_name_length
();
int
schema_len
=
key
->
db_name_length
();
mysql_mutex_lock
(
&
request_thd
->
LOCK_wsrep_thd
);
mysql_mutex_lock
(
&
request_thd
->
LOCK_wsrep_thd
);
/*
We consider granting MDL exceptions only for appliers (BF THD) and ones
executing under TOI mode.
Rules:
1. If granted/owner THD is also an applier (BF THD) or one executing
under TOI mode, then we grant the requested lock to the requester
THD.
@return true
2. If granted/owner THD is executing a FLUSH command or already has an
explicit lock, then do not grant the requested lock to the requester
THD and it has to wait.
@return false
3. In all other cases the granted/owner THD is aborted and the requested
lock is not granted to the requester THD, thus it has to wait.
@return false
*/
if
(
request_thd
->
wsrep_exec_mode
==
TOTAL_ORDER
||
if
(
request_thd
->
wsrep_exec_mode
==
TOTAL_ORDER
||
request_thd
->
wsrep_exec_mode
==
REPL_RECV
)
request_thd
->
wsrep_exec_mode
==
REPL_RECV
)
{
{
...
@@ -1716,7 +1735,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
...
@@ -1716,7 +1735,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
request_thd
,
granted_thd
);
request_thd
,
granted_thd
);
ticket
->
wsrep_report
(
true
);
ticket
->
wsrep_report
(
true
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
ret
=
TRUE
;
ret
=
true
;
}
}
else
if
(
granted_thd
->
lex
->
sql_command
==
SQLCOM_FLUSH
||
else
if
(
granted_thd
->
lex
->
sql_command
==
SQLCOM_FLUSH
||
granted_thd
->
mdl_context
.
has_explicit_locks
())
granted_thd
->
mdl_context
.
has_explicit_locks
())
...
@@ -1724,38 +1743,39 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
...
@@ -1724,38 +1743,39 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
WSREP_DEBUG
(
"BF thread waiting for FLUSH"
);
WSREP_DEBUG
(
"BF thread waiting for FLUSH"
);
ticket
->
wsrep_report
(
wsrep_debug
);
ticket
->
wsrep_report
(
wsrep_debug
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
ret
=
FALSE
;
ret
=
false
;
}
else
if
(
request_thd
->
lex
->
sql_command
==
SQLCOM_DROP_TABLE
)
{
WSREP_DEBUG
(
"DROP caused BF abort"
);
ticket
->
wsrep_report
(
wsrep_debug
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
wsrep_abort_thd
((
void
*
)
request_thd
,
(
void
*
)
granted_thd
,
1
);
ret
=
FALSE
;
}
else
if
(
granted_thd
->
wsrep_query_state
==
QUERY_COMMITTING
)
{
WSREP_DEBUG
(
"MDL granted, but committing thd abort scheduled"
);
ticket
->
wsrep_report
(
wsrep_debug
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
wsrep_abort_thd
((
void
*
)
request_thd
,
(
void
*
)
granted_thd
,
1
);
ret
=
FALSE
;
}
}
else
else
{
{
WSREP_MDL_LOG
(
DEBUG
,
"MDL conflict-> BF abort"
,
schema
,
schema_len
,
/* Print some debug information. */
request_thd
,
granted_thd
);
if
(
wsrep_debug
)
ticket
->
wsrep_report
(
wsrep_debug
);
{
if
((
request_thd
->
lex
->
sql_command
==
SQLCOM_DROP_TABLE
))
{
WSREP_DEBUG
(
"DROP caused BF abort"
);
}
else
if
((
granted_thd
->
wsrep_query_state
==
QUERY_COMMITTING
))
{
WSREP_DEBUG
(
"MDL granted, but committing thd abort scheduled"
);
}
else
{
WSREP_MDL_LOG
(
DEBUG
,
"MDL conflict-> BF abort"
,
schema
,
schema_len
,
request_thd
,
granted_thd
);
}
ticket
->
wsrep_report
(
true
);
}
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
mysql_mutex_unlock
(
&
granted_thd
->
LOCK_wsrep_thd
);
wsrep_abort_thd
((
void
*
)
request_thd
,
(
void
*
)
granted_thd
,
1
);
wsrep_abort_thd
((
void
*
)
request_thd
,
(
void
*
)
granted_thd
,
1
);
ret
=
FALSE
;
ret
=
false
;
}
}
}
}
else
else
{
{
mysql_mutex_unlock
(
&
request_thd
->
LOCK_wsrep_thd
);
mysql_mutex_unlock
(
&
request_thd
->
LOCK_wsrep_thd
);
}
}
return
ret
;
return
ret
;
}
}
...
...
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