[MDEV-21330] Lock monitor doesn't print a semaphore's last reserved thread in non-debug builds and INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS is totally broken Created: 2019-12-17 Updated: 2023-05-30 Resolved: 2023-05-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Information Schema, Storage Engine - InnoDB |
| Affects Version/s: | 10.2.30, 10.3.21, 10.4.11 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Julien Fritsch |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
When a semaphore wait is in progress, InnoDB prints information about the wait in sync_array_cell_print(): https://github.com/MariaDB/server/blob/mariadb-10.2.30/storage/innobase/sync/sync0arr.cc#L478 This function prints the following information:
The information about where the semaphore was last reserved is some of the most useful information available, since it can often give clues about what kind of statement may be holding the semaphore. Unfortunately, for most kinds of semaphores, it appears that this information is only printed in debug builds. We can see that it is dependent on UNIV_DEBUG. i.e.:
For the INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS table, the rows are built in the sync_arr_fill_sys_semphore_waits_table() function: https://github.com/MariaDB/server/blob/mariadb-10.2.30/storage/innobase/sync/sync0arr.cc#L1292 In that function, a lot of the fields are not filled out in any build, because some code is commented out. i.e.:
|
| Comments |
| Comment by Marko Mäkelä [ 2019-12-17 ] |
|
It is possible that the underlying information is not available in release builds, to reduce the memory footprint. Perhaps we should handle buf_block_t as a special case? Also, perhaps the latches could store a short numeric index into an array of all potential locations where they can be acquired? |
| Comment by Marko Mäkelä [ 2020-05-27 ] |
|
|
| Comment by Eugene Kosov (Inactive) [ 2020-07-30 ] |
|
I've added filename and line number variables to mutexes. Every thread updates when taking a lock and this is a possible scalability issue. It was measured. For SSD max measured slowdown is 0.68% and for RAM filesystem it is 0.9%. Is it a lot or a little? We have tickets like https://jira.mariadb.org/browse/MDEV-7962 wsrep_on() takes 0.14% in OLTP RO and https://jira.mariadb.org/browse/MDEV-21212 buf_page_get_gen |
| Comment by Marko Mäkelä [ 2020-09-01 ] |
|
Even if there was no observable performance regression, I would rather not add any instrumentation to the InnoDB homebrew mutexes, because in |
| Comment by Marko Mäkelä [ 2020-12-17 ] |
|
The view INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS that was introduced in Since MariaDB Server 10.2.2, the view only covered InnoDB rw-locks. The rw-lock implementation was replaced in MariaDB 10.6.0 in |
| Comment by Marko Mäkelä [ 2023-05-16 ] |
|
What is the use case for which this is needed in MariaDB Server 10.4 and 10.5? For debugging hangs like |