For the purposes of diagnosing performance issues, what kinds of operations might wait their turn for this mutex, and what configuration options and resources might influence contention on it?
Mysql – the MySQL Mutex called “srv_sys_mutex”
MySQLperformance
Related Solutions
I've seen this very issue and the hotfix that was ultimately released to fix it was actually a direct result of my case with Microsoft CSS. There is no public KB article for the fix. Please make sure you've applied Service Pack 4 and the most recent cumulative update to SQL Server (at the time of writing, that's Cumulative Update #3 (9.00.5259)).
Until the hotfix was released, Microsoft's suggestion was to simply stop creating #temp tables (much like KB #916086). Since this would have meant a substantial re-write of dozens and dozens of reporting procedures, the workaround in my case (regardless of trace flags or temp file layout) was to restart our cluster every other weekend. Yuck.
In order to track down tempdb usage, there are several scripts around that can help, e.g. see Adam Machanic's sp_whoIsActive, specifically:
- sp_whoisactive: Analyzing Tempdb Contention
- How to identify which query is filling up the tempdb transaction log?
And also this script (and ones in the comments) from @SQLSoldier:
I would make sure all your cursors are using LOCAL STATIC READ_ONLY FORWARD_ONLY
(see this and this), and see if there are any known expensive queries that make extensive use of #temp tables / @table variables, CTEs, or may contain unnecessary sorts or lead to hash joins... all of which can contribute to the problem (I doubt you'll find one golden cause). The easiest sweeping fix as a "bang-for-your-buck" starting point will be to use proper and inexpensive cursor options instead of the defaults.
In the meantime I would (a) install CU#3 and (b) call PSS. Tell them you are after a very specific fix that has already been confirmed as a bug and released to other users as a private hotfix: "VSTS #109112 - Temp table deferred drop doesn't scale for certain workloads." You may have to pay the case fee initially but, since it is a bug, the charge should be refunded.
Since you are running MySQL 5.5, have you considering tuning InnoDB for better performance?
There are several variables that have been added to the MySQL 5.1 InnoDB Plugin that are now native to MySQL 5.5. They usually help increase hyperthreading and take advantage of more IOPS if the environment can handled it. In your case, you should be able to.
I have spun RDS models before (See my post : Local database vs Amazon RDS) and can tell you that RDS is not very helpful in tuning InnoDB. You will have to take the bull by the horns on this one.
When you spun up the RDS instance, you probably used the default DB Parameter Group
You should be able to create a new DB Parameter Group for yourself. When you get to this, set the following:
- innodb_read_io_threads : Highest allowed is 64. In RDS, highest allowed is 16. Default is 4.
- innodb_write_io_threads : Highest allowed is 64. In RDS, highest allowed is 16. Default is 4.
- innodb_thread_concurrency : Default is already 0. Never set this value to any other number.
I suggest these because they are default in RDS for innodb_read_io_threads and innodb_write_io_threads are just too low. In addition, your SHOW ENGINE INNODB STATUS\G
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
only shows the default of 4 for each class of io threads.
Here is the Bad News: To implement config changes, once you create your own DB Parameter Group, you must export the data from the old RDS instance, create a new instance using your new DB Parameter Group, and reload. In more detail...
- Create a Custom DB Parameter Group (call it
MySettings
) - Download RDS CLI and setup a config file with your AWS Credentials
- Execute the following :
./rds-modify-db-parameter-group MySettings --parameters "name=innodb_read_io_threads,value=16,method=immediate"
- Modify using DB Parameter Option List
MySettings
- Restart the MySQL RDS Instance
I hope this helps !!!
Related Question
- How to use? A string or 15 integer fields
- Oracle – Best Way to Insert XML Input to Table in Stored Procedure
- Mysql – Slow MySql Server Performance – What and How to check
- MySQL: How to calculate potential wait time
- MySQL Hardware Bottleneck
- Postgresql – What configurations affect the speed of DDL statements in PostgreSQL
Best Answer
It's a system mutex. It's used to protect creating new threads, destroying them. I guess, thread_cache_size may ease contention on it.