#167 Mixing transaction and non-transaction plugins can cause deadlock
Closed: wontfix None Opened 12 years ago by rmeggins.

https://bugzilla.redhat.com/show_bug.cgi?id=759183

Description of problem:

If memberof is configured as a betxnpostoperation plugin then modifying group
membership can deadlock ns-slapd.

Version-Release number of selected component (if applicable):

389-ds-base-1.2.10-0.5.a5.fc15.x86_64

Steps to Reproduce:
1. Install and configure an IPA server
2. set nsslapd-plugintype for memberof to betxnpostoperation
3. ipa group-add-member --users=admin editors
<lock>

Additional info:

#0  pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:165
#1  0x00007fe04c8e3b5b in __db_pthread_mutex_lock (env=0xc504f0,
    mutex=<optimized out>) at ../../mutex/mut_pthread.c:318

#2  0x00007fe04c8e314a in __db_tas_mutex_lock_int (nowait=0, mutex=1209,
    env=0xc504f0) at ../../mutex/mut_tas.c:218
#3  __db_tas_mutex_lock_int (nowait=0, mutex=1209, env=0xc504f0)
    at ../../mutex/mut_tas.c:244
#4  __db_tas_mutex_lock (env=0xc504f0, mutex=1209) at ../../mutex/mut_tas.c:248
#5  0x00007fe04c972d83 in __lock_get_internal (lt=0xb9a640,
    sh_locker=<optimized out>, flags=0, obj=0x3015, lock_mode=<optimized out>,
    timeout=0, lock=0x7fe0267dc8f0) at ../../lock/lock.c:953
#6  0x00007fe04c9732c2 in __lock_get (env=<optimized out>,
    locker=0x7fe04917b180, flags=<optimized out>, obj=<optimized out>,
    lock_mode=<optimized out>, lock=<optimized out>) at ../../lock/lock.c:459
#7  0x00007fe04c9a22d6 in __db_lget (dbc=<optimized out>, action=0,
    pgno=<optimized out>, mode=<optimized out>, lkflags=<optimized out>,
    lockp=0x7fe0267dc8f0) at ../../db/db_meta.c:1203
#8  0x00007fe04c900ac8 in __bam_search (dbc=0xb9e150, root_pgno=1,
    key=0x7fe0267dcf00, flags=12802, slevel=1, recnop=0x0,
    exactp=0x7fe0267dca9c) at ../../btree/bt_search.c:702
#9  0x00007fe04c8ec1b6 in __bamc_search (dbc=0xb9e150, root_pgno=1,
    key=0x7fe0267dcf00, flags=<optimized out>, exactp=0x7fe0267dca9c)
    at ../../btree/bt_cursor.c:2785
#10 0x00007fe04c8f0495 in __bamc_put (dbc=0xb9e150, key=0x7fe0267dcf00,
    data=0x7fe0267dced0, flags=14, pgnop=0x7fe0267dcafc)
    at ../../btree/bt_cursor.c:2130
#11 0x00007fe04c9928e9 in __dbc_iput (dbc=0xb9e150, key=0x7fe0267dcf00,
    data=0x7fe0267dced0, flags=14) at ../../db/db_cam.c:2103
#12 0x00007fe04c9946a9 in __dbc_put (dbc=<optimized out>, key=0x7fe0267dcf00,
    data=0x7fe0267dced0, flags=14) at ../../db/db_cam.c:2016
#13 0x00007fe04c986c5e in __db_put (dbp=0xc40bb0, ip=<optimized out>,
    txn=<optimized out>, key=0x7fe0267dcf00, data=0x7fe0267dced0, flags=0)
    at ../../db/db_am.c:477
#14 0x00007fe04c99f3cb in __db_put_pp (dbp=0xc40bb0, txn=0x7fe00c01d900,
    key=0x7fe0267dcf00, data=0x7fe0267dced0, flags=0)
    at ../../db/db_iface.c:1579
#15 0x00007fe04cc63c76 in id2entry_add_ext (be=0xaed320, e=0x7fe00c018030,
    txn=0x7fe0267dd030, encrypt=<optimized out>)
    at ldap/servers/slapd/back-ldbm/id2entry.c:135
#16 0x00007fe04cc8f20a in ldbm_back_modify (pb=0x7fe00c01a6e0)
    at ldap/servers/slapd/back-ldbm/ldbm_modify.c:445
#17 0x000000339627bd53 in op_shared_modify (pb=<optimized out>, pw_change=0,
    old_pw=0x0) at ldap/servers/slapd/modify.c:903
#18 0x000000339627c175 in modify_internal_pb (pb=0x7fe00c01a6e0)
    at ldap/servers/slapd/modify.c:584
#19 0x00007fe04c2348eb in mep_mod_post_op (pb=<optimized out>)
    at ldap/servers/plugins/mep/mep.c:2124
#20 0x00000033962891fd in plugin_call_func (list=0xaae970, operation=521,
    pb=0x7fe00c00d130, call_one=0) at ldap/servers/slapd/plugin.c:1448
#21 0x00000033962893e4 in plugin_call_list (pb=0x7fe00c00d130, operation=521,
    list=<optimized out>) at ldap/servers/slapd/plugin.c:1410
#22 plugin_call_plugins (pb=0x7fe00c00d130, whichfunction=521)
    at ldap/servers/slapd/plugin.c:395
#23 0x000000339627bdee in op_shared_modify (pb=<optimized out>, pw_change=0,
    old_pw=0x0) at ldap/servers/slapd/modify.c:940
#24 0x000000339627c175 in modify_internal_pb (pb=0x7fe00c00d130)
    at ldap/servers/slapd/modify.c:584
#25 0x00007fe04c029a5c in memberof_fix_memberof_callback (e=<optimized out>,
    callback_data=0x7fe0267e5730)
    at ldap/servers/plugins/memberof/memberof.c:2431
#26 0x00007fe04c02a24d in memberof_modop_one_replace_r (pb=0xdf8a40,
    config=0x7fe0267e58b0, mod_op=0,
    group_dn=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    op_this=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    replace_with=0x0,
    op_to=0x7fe00c007b10 "uid=admin,cn=users,cn=accounts,dc=example,dc=com",
stack=0x0, txn=0x7fe00c00b5c0) at ldap/servers/plugins/memberof/memberof.c:1308
#27 0x00007fe04c02ad0c in memberof_modop_one_r (stack=0x0, txn=0x7fe00c00b5c0,
    op_to=<optimized out>,
    op_this=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    group_dn=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    mod_op=0, config=0x7fe0267e58b0, pb=0xdf8a40)
    at ldap/servers/plugins/memberof/memberof.c:1087
#28 memberof_modop_one (mod_op=0, txn=0x7fe00c00b5c0, op_to=<optimized out>,
    op_this=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    config=0x7fe0267e58b0, pb=0xdf8a40)
    at ldap/servers/plugins/memberof/memberof.c:1076
#29 memberof_add_one (txn=0x7fe00c00b5c0, addto=<optimized out>,
    addthis=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    config=0x7fe0267e58b0, pb=0xdf8a40)
    at ldap/servers/plugins/memberof/memberof.c:1373
#30 memberof_replace_list (pb=0xdf8a40, config=0x7fe0267e58b0,
    group_dn=0x7fe00c0039f0
"cn=editors,cn=groups,cn=accounts,dc=example,dc=com",
    txn=0x7fe00c00b5c0) at ldap/servers/plugins/memberof/memberof.c:2121
#31 0x00007fe04c02b7cb in memberof_postop_modify (pb=0xdf8a40)
    at ldap/servers/plugins/memberof/memberof.c:892
#32 0x00000033962891fd in plugin_call_func (list=0xab20c0, operation=561,
    pb=0xdf8a40, call_one=0) at ldap/servers/slapd/plugin.c:1448
#33 0x00000033962893e4 in plugin_call_list (pb=0xdf8a40, operation=561,
    list=<optimized out>) at ldap/servers/slapd/plugin.c:1410
#34 plugin_call_plugins (pb=0xdf8a40, whichfunction=561)
    at ldap/servers/slapd/plugin.c:395
#35 0x00007fe04cc8f733 in ldbm_back_modify (pb=0xdf8a40)
    at ldap/servers/slapd/back-ldbm/ldbm_modify.c:557
#36 0x000000339627bd53 in op_shared_modify (pb=<optimized out>, pw_change=0,
    old_pw=0x0) at ldap/servers/slapd/modify.c:903
#37 0x000000339627c940 in do_modify (pb=0xdf8a40)
    at ldap/servers/slapd/modify.c:372
#38 0x0000000000416d3e in connection_dispatch_operation (pb=<optimized out>,
    op=0xde6140, conn=0x7fe044273560) at ldap/servers/slapd/connection.c:583
#39 connection_threadmain () at ldap/servers/slapd/connection.c:2328
#40 0x0000003ab9828553 in _pt_root (arg=0xe1d280)
    at ../../../mozilla/nsprpub/pr/src/pthreads/ptthread.c:187
#41 0x0000003bf9007b31 in start_thread (arg=0x7fe0267ec700)
    at pthread_create.c:305
#42 0x0000003bf88dfd2d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

batch move to milestone 1.2.10.a7

Looks like when you create the database with DB_CREATE|DB_RECOVER|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_INIT_MPOOL|DB_THREAD
and open the db with DB_CREATE|DB_AUTO_COMMIT|DB_THREAD

and you open a transaction, the transaction locks out the db, preventing any other transaction, or any operation without a transaction, to access the db

Even adding DB_READ_UNCOMMITTED doesn't help - the txn still locks out the db

Looks like we need to convert all plugins to be transaction aware . . .

To ssh://git.fedorahosted.org/git/389/ds.git
e1a7823..77fdecc master -> master
commit changeset:77fdecc/389-ds-base
Author: Rich Megginson rmeggins@redhat.com
Date: Wed Jan 11 15:04:05 2012 -0700
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Make all code that uses internal database operations be
transaction aware. This excludes code that works exclusively on the
config DSEs such as cn=schema or cn=config. This also excludes code in
a couple of areas, because of difficulty in passing in the txn handle:
1) views_entry_exists Slapi APIB functions
2) acllas.c code that does internal searching
3) cos_cache_follow_pointer()
Also allow dna, linkedattrs, automember, and mep to run as betxn plugins by
configuring the plugin config entry in the dse
Platforms tested: RHEL6 x86_64, Fedora 16
Flag Day: no
Doc impact: no

Replying to [comment:5 rmeggins]:

Looks like we need to convert all plugins to be transaction aware . . .
[[br]]
Does it mean that all the third-party plugins need to be rewritten in transaction-aware manner? If it is the case the documentation on plugin development should also be changed...

Replying to [comment:9 pj101]:

Replying to [comment:5 rmeggins]:

Looks like we need to convert all plugins to be transaction aware . . .
[[br]]
Does it mean that all the third-party plugins need to be rewritten in transaction-aware manner?

If it is possible that they can be called from within a betxn pre or post operation plugin, then yes.

If it is the case the documentation on plugin development should also be changed...

Yes.

The new strategy is to use Thread Local Storage to store the transaction handle so plugins don't have to know anything about transactions.

To ssh://git.fedorahosted.org/git/389/ds.git
144af59..85d44fc master -> master
commit changeset:85d44fc/389-ds-base
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Feb 16 17:22:56 2012 -0700
Revert "pass the plugin config entry to the plugin init function"
This reverts commit changeset:b6d3ba7/389-ds-base
Reverts only the txn code
commit changeset:a1201df/389-ds-base
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Feb 16 17:16:11 2012 -0700
Revert "make memberof transaction aware and able to be a betxnpostoperation plugin"
This reverts commit changeset:1d2f5a0/389-ds-base
Reverts the SLAPI_TXN stuff but leaves the code that allows memberof to
be either a regular or a betxn plugin.
commit changeset:4022896/389-ds-base
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Feb 16 17:08:23 2012 -0700
Revert "Change referential integrity to be a betxnpostoperation plugin"
This reverts commit changeset:d316a67/389-ds-base
keep the code that allows switching between a regular and a betxn
plugin
commit changeset:dc9bfe9/389-ds-base
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Feb 16 12:51:23 2012 -0700
Revert "Ticket #167 - Mixing transaction and non-transaction plugins can cause deadlock"
This reverts commit changeset:77fdecc/389-ds-base
This is a partial revert. We still want to keep the code in the plugins
that allows them to be either a regular plugin or a betxn plugin. All
of the code that dealt with SLAPI_TXN and making sure all internal
operations had SLAPI_TXN set is gone. We will
come up with a new mechanism for keeping track of the original requestor
DN, most likely a scheme using Thread Local Storage (TLS).

Added initial screened field value.

Metadata Update from @nkinder:
- Issue assigned to rmeggins
- Issue set to the milestone: 1.2.11.a1

7 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/167

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

3 years ago

Login to comment on this ticket.

Metadata