Bug 1273552 - Deadlock between two MODs on the same entry between entry cache and backend lock
Deadlock between two MODs on the same entry between entry cache and backend lock
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: 389-ds-base (Show other bugs)
6.6
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
Petr Bokoc
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-20 12:51 EDT by Noriko Hosoi
Modified: 2016-05-10 15:22 EDT (History)
6 users (show)

See Also:
Fixed In Version: 389-ds-base-1.2.11.15-67.el6
Doc Type: Bug Fix
Doc Text:
*389-ds-base* no longer hangs due to modified entry remaining locked During a modify operation, the modified entry is inserted into entry cache and locked until the modified entry is returned. In cases where the entry is removed from the entry cache after it is committed but before the return operation, the modified entry previously remained locked, and any subsequent write operations on the same entry then caused the server to hang. This bug has been fixed by adding a flag so that the entry can be unlocked whether it is present in the entry cache or not, and the server no longer hangs in this situation.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-05-10 15:22:01 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Noriko Hosoi 2015-10-20 12:51:41 EDT
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/389/ticket/47978

The deadlock occurs when two MODS target the same entry.
One MOD locks the entry in the entry cache (find_entry_internal ?) then tries to acquire the backend lock (in txn_begin).
The second MOD acquired the backend lock (txn_begin) and hangs while locking the entry in the entry cache (cache_lock_entry).

The deadlock occurs while doing performance measurement.
To do this performance and skip the IOs bottleneck, I tuned the :
        - nsslapd-threadnumber: 100
        - nsslapd-db-transaction-batch-val: 100
        - nsslapd-backend-opt-level: 7

This tuning helped to reproduce the hang but are not the cause of the hang.

Deadlock:

MOD ("cn=mr000006001,o=People,o=test_bis_create")
Thread 89 (Thread 0x7f84a97fa700 (LWP 13200)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f84d1118943 in PR_EnterMonitor (mon=0x7f84480064b0) at ../../../nspr/pr/src/pthreads/ptsynch.c:592
#2  0x00007f84c8a2795a in cache_lock_entry () from /usr/lib64/dirsrv/plugins/libback-ldbm.so
#3  0x00007f84c8a6bde0 in ldbm_back_modify () from /usr/lib64/dirsrv/plugins/libback-ldbm.so
#4  0x00007f84d2d1c8e1 in op_shared_modify () from /usr/lib64/dirsrv/libslapd.so.0
#5  0x00007f84d2d1dc1f in do_modify () from /usr/lib64/dirsrv/libslapd.so.0
#6  0x00007f84d31fc3c1 in connection_threadmain ()
#7  0x00007f84d111de3b in _pt_root (arg=0x7f84d46f7b30) at ../../../nspr/pr/src/pthreads/ptthread.c:212
#8  0x00007f84d0abdee5 in start_thread (arg=0x7f84a97fa700) at pthread_create.c:309
#9  0x00007f84d07ecb8d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

MOD ("cn=mr000006001,o=People,o=test_bis_create")
Thread 87 (Thread 0x7f84a87f8700 (LWP 13202)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f84d1118943 in PR_EnterMonitor (mon=0x7f84d3feb9d0) at ../../../nspr/pr/src/pthreads/ptsynch.c:592
#2  0x00007f84c8a2c3b7 in dblayer_lock_backend () from /usr/lib64/dirsrv/plugins/libback-ldbm.so
#3  0x00007f84c8a311be in dblayer_txn_begin () from /usr/lib64/dirsrv/plugins/libback-ldbm.so
#4  0x00007f84c8a6ca77 in ldbm_back_modify () from /usr/lib64/dirsrv/plugins/libback-ldbm.so
#5  0x00007f84d2d1c8e1 in op_shared_modify () from /usr/lib64/dirsrv/libslapd.so.0
#6  0x00007f84d2d1dc1f in do_modify () from /usr/lib64/dirsrv/libslapd.so.0
#7  0x00007f84d31fc3c1 in connection_threadmain ()
#8  0x00007f84d111de3b in _pt_root (arg=0x7f84d47321b0) at ../../../nspr/pr/src/pthreads/ptthread.c:212
#9  0x00007f84d0abdee5 in start_thread (arg=0x7f84a87f8700) at pthread_create.c:309

To reproduce:

On F20 - 389-DS 1.3.4
32 cores hardware machine: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
32 Gb memory

Install 389-DS 1.3.4 (master branch c3389a46c584fa39b2278a295f8b2b6dad726d31)
Create a suffix and trigger MOD update on low number of entries (using ldclt) so that several mods apply to the same entry
Comment 3 thierry bordaz 2016-01-11 05:17:16 EST
Hi Amita,

I used a IPA CI test (more specifically a KRA test).
I updated the upstream ticket with the details how to run the tests in https://fedorahosted.org/389/ticket/47978#comment:19

thanks
thierry
Comment 4 Amita Sharma 2016-01-12 04:22:33 EST
(In reply to thierry bordaz from comment #3)
> Hi Amita,
> 
> I used a IPA CI test (more specifically a KRA test).
> I updated the upstream ticket with the details how to run the tests in
> https://fedorahosted.org/389/ticket/47978#comment:19
Thanks Thierry,

I did some investigation and discussed with Kaleem about it.
Above mentioned test is designed for RHEL7 (involved vault), and not for rhel6.

Here is the job which failed, for rhel6 for the test case -
https://beaker.engineering.redhat.com/jobs/1187968

So, can you please mention how it can be tested on rhel6.

Thanks & Regards,
Amita
> 
> thanks
> thierry
Comment 5 thierry bordaz 2016-01-12 05:03:34 EST
Hi Amita,

The bug is dynamic. DS is using an entry cache and the bug occurs if an entry was in the entry cache during the update but no longer in the entry cache at the end of the update. This is something difficult to acheive.

I think you can try to reproduce with something like:
  - provision 1000 entries
  - stop DS, set nsslapd-cachesize=10, start DS
  - run load of unindexed searches or simple lookup all the entries
  - Then during the load, do an update on an entry (it can be always the same entry).

This test case can be sufficient to reproduce but it is difficult to be sure it will succeeds.


thanks
theirry
Comment 6 Amita Sharma 2016-02-04 05:38:08 EST
Followed steps in comment#5
[root@vm-idm-001 export]# rpm -qa | grep 389
389-ds-base-1.2.11.15-72.el6.x86_64
389-ds-base-libs-1.2.11.15-72.el6.x86_64

[root@vm-idm-001 export]# i=10; while [ $i > 10 ]; do ldapsearch -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 -b "dc=example,dc=com"; i=`expr $i - 1`; done

[root@vm-idm-001 ~]# ldapmodify -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 << EOF
dn: uid=FBechtel998,ou=Accounting,dc=example,dc=com
changetype: modify
replace: employeeType
employeeType: Super       
EOF
modifying entry "uid=FBechtel998,ou=Accounting,dc=example,dc=com"

[root@vm-idm-001 ~]# ldapmodify -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 << EOF
dn: uid=FBechtel998,ou=Accounting,dc=example,dc=com
changetype: modify
replace: employeeType
employeeType: Supe1r
EOF

modifying entry "uid=FBechtel998,ou=Accounting,dc=example,dc=com"

[root@vm-idm-001 ~]# ldapmodify -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 << EOF
dn: uid=FBechtel998,ou=Accounting,dc=example,dc=com
changetype: modify
replace: employeeType
employeeType: Supe1r1
EOF

modifying entry "uid=FBechtel998,ou=Accounting,dc=example,dc=com"

[root@vm-idm-001 ~]# ldapmodify -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 << EOF
dn: uid=FBechtel998,ou=Accounting,dc=example,dc=com
changetype: modify
replace: employeeType
employeeType: Supe1r11
EOF

modifying entry "uid=FBechtel998,ou=Accounting,dc=example,dc=com"

[root@vm-idm-001 ~]# ldapmodify -x -h localhost -p 389 -D "cn=directory manager" -w Secret123 << EOF
dn: uid=FBechtel998,ou=Accounting,dc=example,dc=com
changetype: modify
replace: employeeType
employeeType: Supe1211
EOF

modifying entry "uid=FBechtel998,ou=Accounting,dc=example,dc=com"

Nothing seems to fail here, marking bug as VERIFIED.
Comment 8 errata-xmlrpc 2016-05-10 15:22:01 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0737.html

Note You need to log in before you can comment on or make changes to this bug.