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
98207ad5
Commit
98207ad5
authored
Dec 01, 2020
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Register waits in PERFORMANCE_SCHEMA even before trylock
parent
1218f68b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
34 deletions
+97
-34
mysql-test/suite/perfschema/r/sxlock_func.result
mysql-test/suite/perfschema/r/sxlock_func.result
+34
-11
mysql-test/suite/perfschema/t/sxlock_func.test
mysql-test/suite/perfschema/t/sxlock_func.test
+57
-5
storage/innobase/include/srw_lock.h
storage/innobase/include/srw_lock.h
+6
-18
No files found.
mysql-test/suite/perfschema/r/sxlock_func.result
View file @
98207ad5
UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
UPDATE performance_schema.setup_instruments SET enabled = 'YES'
WHERE name like 'wait/synch/sxlock/%';
select distinct name from performance_schema.setup_instruments
where name like "wait/synch/rwlock/innodb%"
and name!='wait/synch/rwlock/innodb/btr_search_latch' order by name;
name
wait/synch/rwlock/innodb/dict_operation_lock
wait/synch/rwlock/innodb/fil_space_latch
wait/synch/rwlock/innodb/trx_i_s_cache_lock
wait/synch/rwlock/innodb/trx_purge_latch
select distinct name from performance_schema.rwlock_instances
where name like 'wait/synch/sxlock/%'
order by name;
TRUNCATE TABLE performance_schema.events_waits_history_long;
TRUNCATE TABLE performance_schema.events_waits_history;
TRUNCATE TABLE performance_schema.events_waits_current;
select name from performance_schema.setup_instruments
where name like "wait/synch/sxlock/%" order by name;
name
wait/synch/sxlock/innodb/index_tree_rw_lock
select name from performance_schema.rwlock_instances
where name in
(
'wait/synch/sxlock/innodb/btr_search_latch',
'wait/synch/sxlock/innodb/checkpoint_lock',
'wait/synch/sxlock/innodb/dict_operation_lock',
'wait/synch/sxlock/innodb/trx_i_s_cache_lock',
'wait/synch/sxlock/innodb/trx_purge_latch'
)
order by name;
name
drop table if exists t1;
create table t1(a int) engine=innodb;
begin;
insert into t1 values (1), (2), (3);
insert into t1 values (1), (2), (3);
insert into t1 values (1), (2), (3);
commit;
drop table t1;
select operation from performance_schema.events_waits_history_long
where event_name like "wait/synch/sxlock/%"
and operation = "shared_lock" limit 1;
operation
shared_lock
select operation from performance_schema.events_waits_history_long
where event_name like "wait/synch/sxlock/%"
and operation = "exclusive_lock" limit 1;
operation
exclusive_lock
UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
mysql-test/suite/perfschema/t/sxlock_func.test
View file @
98207ad5
...
...
@@ -11,13 +11,65 @@ UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
UPDATE
performance_schema
.
setup_instruments
SET
enabled
=
'YES'
WHERE
name
like
'wait/synch/sxlock/%'
;
select
distinct
name
from
performance_schema
.
setup_instruments
where
name
like
"wait/synch/rwlock/innodb%"
and
name
!=
'wait/synch/rwlock/innodb/btr_search_latch'
order
by
name
;
TRUNCATE
TABLE
performance_schema
.
events_waits_history_long
;
TRUNCATE
TABLE
performance_schema
.
events_waits_history
;
TRUNCATE
TABLE
performance_schema
.
events_waits_current
;
select
distinct
name
from
performance_schema
.
rwlock_instances
where
name
like
'wait/synch/sxlock/%'
# Check some SX-locks classes are instrumented
select
name
from
performance_schema
.
setup_instruments
where
name
like
"wait/synch/sxlock/%"
order
by
name
;
# Check some SX-locks instances are instrumented
select
name
from
performance_schema
.
rwlock_instances
where
name
in
(
'wait/synch/sxlock/innodb/btr_search_latch'
,
'wait/synch/sxlock/innodb/checkpoint_lock'
,
'wait/synch/sxlock/innodb/dict_operation_lock'
,
'wait/synch/sxlock/innodb/trx_i_s_cache_lock'
,
'wait/synch/sxlock/innodb/trx_purge_latch'
)
order
by
name
;
# Some Innodb payload, to produce data
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
a
int
)
engine
=
innodb
;
begin
;
insert
into
t1
values
(
1
),
(
2
),
(
3
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
commit
;
drop
table
t1
;
# Make sure some shared_lock operations have been executed
select
operation
from
performance_schema
.
events_waits_history_long
where
event_name
like
"wait/synch/sxlock/%"
and
operation
=
"shared_lock"
limit
1
;
# Make sure some exclusive_lock operations have been executed
select
operation
from
performance_schema
.
events_waits_history_long
where
event_name
like
"wait/synch/sxlock/%"
and
operation
=
"exclusive_lock"
limit
1
;
# The following operations are not verified in this test:
# - shared_exclusive_lock
# - try_shared_lock
# - try_shared_exclusive_lock
# - try_exclusive_lock
# because to observe them:
# - there must be an actual code path using the operation
# (this affects try operations, which are not all used)
# - there must be a repeatable scenario to trigger the
# code path, to use as payload in the test script
# Cleanup
UPDATE
performance_schema
.
setup_instruments
SET
enabled
=
'YES'
,
timed
=
'YES'
;
storage/innobase/include/srw_lock.h
View file @
98207ad5
...
...
@@ -46,9 +46,6 @@ class srw_mutex
/** Slim reader-writer lock with no recursion */
class
srw_lock_low
final
:
private
rw_lock
{
#ifdef UNIV_PFS_RWLOCK
friend
class
srw_lock
;
#endif
#ifdef SRW_LOCK_DUMMY
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
...
...
@@ -127,21 +124,18 @@ class srw_lock
template
<
bool
update
=
false
>
void
rd_lock
(
const
char
*
file
,
unsigned
line
)
{
uint32_t
l
;
if
(
lock
.
read_trylock
(
l
))
return
;
if
(
pfs_psi
)
{
PSI_rwlock_locker_state
state
;
PSI_rwlock_locker
*
locker
=
PSI_RWLOCK_CALL
(
start_rwlock_rdwait
)
(
&
state
,
pfs_psi
,
update
?
PSI_RWLOCK_SHAREDLOCK
:
PSI_RWLOCK_READLOCK
,
file
,
line
);
lock
.
r
ead_lock
(
l
);
lock
.
r
d_lock
(
);
if
(
locker
)
PSI_RWLOCK_CALL
(
end_rwlock_rdwait
)(
locker
,
0
);
return
;
}
lock
.
r
ead_lock
(
l
);
lock
.
r
d_lock
(
);
}
void
rd_unlock
()
{
...
...
@@ -153,8 +147,6 @@ class srw_lock
{
if
(
pfs_psi
)
{
if
(
lock
.
u_lock_try
())
return
;
PSI_rwlock_locker_state
state
;
PSI_rwlock_locker
*
locker
=
PSI_RWLOCK_CALL
(
start_rwlock_wrwait
)
(
&
state
,
pfs_psi
,
PSI_RWLOCK_SHAREDEXCLUSIVELOCK
,
file
,
line
);
...
...
@@ -174,8 +166,6 @@ class srw_lock
template
<
bool
update
=
false
>
void
wr_lock
(
const
char
*
file
,
unsigned
line
)
{
if
(
lock
.
write_trylock
())
return
;
if
(
pfs_psi
)
{
PSI_rwlock_locker_state
state
;
...
...
@@ -183,12 +173,12 @@ class srw_lock
(
&
state
,
pfs_psi
,
update
?
PSI_RWLOCK_EXCLUSIVELOCK
:
PSI_RWLOCK_WRITELOCK
,
file
,
line
);
lock
.
wr
ite_lock
(
false
);
lock
.
wr
_lock
(
);
if
(
locker
)
PSI_RWLOCK_CALL
(
end_rwlock_rdwait
)(
locker
,
0
);
return
;
}
lock
.
wr
ite_lock
(
false
);
lock
.
wr
_lock
(
);
}
void
wr_unlock
()
{
...
...
@@ -198,19 +188,17 @@ class srw_lock
}
void
u_wr_upgrade
(
const
char
*
file
,
unsigned
line
)
{
if
(
lock
.
upgrade_trylock
())
return
;
if
(
pfs_psi
)
{
PSI_rwlock_locker_state
state
;
PSI_rwlock_locker
*
locker
=
PSI_RWLOCK_CALL
(
start_rwlock_wrwait
)
(
&
state
,
pfs_psi
,
PSI_RWLOCK_WRITELOCK
,
file
,
line
);
lock
.
write_lock
(
true
);
lock
.
u_wr_upgrade
(
);
if
(
locker
)
PSI_RWLOCK_CALL
(
end_rwlock_rdwait
)(
locker
,
0
);
return
;
}
lock
.
write_lock
(
true
);
lock
.
u_wr_upgrade
(
);
}
bool
rd_lock_try
()
{
return
lock
.
rd_lock_try
();
}
bool
u_lock_try
()
{
return
lock
.
u_lock_try
();
}
...
...
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