# SEMAPHORES - S-lock & X-lock on RW-latch

**URL:** <https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957>\
**Category:** Percona Server for MySQL 5.6\
**Created:** [April 9, 2019, 5:47am UTC](https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957 "2019-04-09T05:47:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pooja.gupta](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@pooja.gupta](https://forums.percona.com/u/pooja.gupta)\
**Post date:** [April 9, 2019, 5:47am UTC](https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957/1 "2019-04-09T05:47:30Z")

</div>

I can see many types of contention in the show engine innodb status\G

Its increasing load on the server , CPU utilization was High and High I/O noticed.

Can see below contentions in error logs.

* * *

## SEMAPHORES

OS WAIT ARRAY INFO: reservation count 197682819  
–Thread 139909836908288 has waited at btr0cur.cc line 591 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x7f3eb0029fa0 ‘&new\_index-\>lock’  
a writer (thread id 139911101409024) has reserved it in mode exclusive  
number of readers 0, waiters flag 1, lock\_word: 0  
Last time read locked in file btr0cur.cc line 591  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/btr/btr0cur.cc line 582

OS WAIT ARRAY INFO: reservation count 197784171  
–Thread 139909319145216 has waited at btr0sea.cc line 1494 for 0.0000 seconds the semaphore:  
X-lock on RW-latch at 0x23d9658 ‘&btr\_search\_latch\_arr[i]’  
a writer (thread id 139909794551552) has reserved it in mode exclusive  
number of readers 0, waiters flag 0, lock\_word: 0  
Last time read locked in file btr0sea.cc line 954  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/btr/btr0sea.cc line 1494

OS WAIT ARRAY INFO: reservation count 202249793  
–Thread 139909786564352 has waited at btr0pcur.cc line 467 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x7f41132df320 ‘&block-\>lock’  
a writer (thread id 139909862520576) has reserved it in mode wait exclusive  
number of readers 1, waiters flag 1, lock\_word: ffffffffffffffff  
Last time read locked in file row0sel.cc line 3346  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/row/row0row.cc line 823

–Thread 139909849413376 has waited at row0sel.cc line 3346 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x7f41132df320 ‘&block-\>lock’  
a writer (thread id 139909862520576) has reserved it in mode wait exclusive  
number of readers 1, waiters flag 1, lock\_word: ffffffffffffffff  
Last time read locked in file row0sel.cc line 3346  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/row/row0row.cc line 823

–Thread 139909836089088 has waited at row0sel.cc line 3346 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x7f406d31ed20 ‘&block-\>lock’  
number of readers 1, waiters flag 0, lock\_word: fffff  
Last time read locked in file row0sel.cc line 3346  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/row/row0ins.cc line 2718

–Thread 139909854123776 has waited at buf0buf.cc line 3303 for 0.0000 seconds the semaphore:  
Mutex at 0x7f40a4ad8840 ‘&block-\>mutex’, lock var 0  
waiters flag 0  
–Thread 139909777962752 has waited at btr0sea.cc line 1380 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x23d9658 ‘&btr\_search\_latch\_arr[i]’  
number of readers 4, waiters flag 0, lock\_word: ffffc  
Last time read locked in file btr0sea.cc line 954

–Thread 139909845509888 has waited at btr0pcur.cc line 467 for 0.0000 seconds the semaphore:  
S-lock on RW-latch at 0x7f41132df320 ‘&block-\>lock’  
a writer (thread id 139909862520576) has reserved it in mode wait exclusive  
number of readers 1, waiters flag 1, lock\_word: ffffffffffffffff  
Last time read locked in file row0sel.cc line 3346  
Last time write locked in file /mnt/workspace/percona-server-5.6-redhat-binary/label\_exp/centos7-64/rpmbuild/BUILD/percona-server-5.6.39-83.1/storage/innobase/row/row0row.cc line 823

Mysql version is 5.6.39-83.1

Do i need to set innodb\_thread\_concurrency to some value,  
currently its innodb\_thread\_concurrency =0, innodb\_buffer\_pool\_instances =1, innodb\_read\_io\_threads=64, innodb\_write\_io\_threads=64, innodb\_adaptive\_hash\_index=ON.

All tables are innodb .

Buffer pool size is 80GB.

Total memory on the servers is 125GB and 8 core’s CPU

---

<div class="post-metadata">

**Author:** ![pooja.gupta](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@pooja.gupta](https://forums.percona.com/u/pooja.gupta)\
**Post date:** [April 10, 2019, 8:45pm UTC](https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957/2 "2019-04-10T20:45:11Z")

</div>

Hi,

Do I need to adjust below parameters ?

±--------------------------±------+  
| Variable\_name | Value |  
±--------------------------±------+  
| innodb\_thread\_concurrency | 0 |  
±--------------------------±------+

±-----------------------±------+  
| Variable\_name | Value |  
±-----------------------±------+  
| innodb\_read\_io\_threads | 64 |  
±-----------------------±------+

±------------------------±------+  
| Variable\_name | Value |  
±------------------------±------+  
| innodb\_write\_io\_threads | 64 |  
±------------------------±------+

±--------------------------------------±------+  
| Variable\_name | Value |  
±--------------------------------------±------+  
| innodb\_adaptive\_hash\_index | ON |  
±--------------------------------------±------+

±-----------------------------±------+  
| Variable\_name | Value |  
±-----------------------------±------+  
| innodb\_buffer\_pool\_instances | 1 |  
±-----------------------------±------+

Looking for expert opinion, Any help will be appreciated.

Thanks,  
Pooja.

---

<div class="post-metadata">

**Author:** ![bowenzhuang](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bowenzhuang](https://forums.percona.com/u/bowenzhuang)\
**Post date:** [June 29, 2020, 2:32am UTC](https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957/3 "2020-06-29T02:32:01Z")

</div>

i also encountered the same problem in mysql 5.6.40 .&nbsp;  
Looking for expert opinion, Any help will be appreciated. +1&nbsp;

---

<div class="post-metadata">

**Author:** ![vaibhav\_upadhyay40](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vaibhav_upadhyay40/32/9_2.png) [@vaibhav\_upadhyay40](https://forums.percona.com/u/vaibhav_upadhyay40)\
**Post date:** [July 1, 2020, 4:48pm UTC](https://forums.percona.com/t/semaphores-s-lock-x-lock-on-rw-latch/6957/4 "2020-07-01T16:48:37Z")

</div>

Hi @bowenzhuang and @“pooja.gupta”   
  
Check hash and non-hash search in innodb engine output.&nbsp;If its ok to test in your environment to disable&nbsp;innodb\_adaptive\_hash\_index, please do so&nbsp;and monitor for the performance and for the above issue.  
  
@“pooja.gupta”   
  
apart from this, i would recommend to split the buffer pool into multiple instances.&nbsp;  
Hope this helps.
