Skip to content

Regression test in betxn_test.py failing due to busy LDAP server #6595

Closed

Description

@abeisemb

Issue Description
The regression test dirsrvtests/tests/suites/betxns/betxn_test.py::test_betxn_modrdn_memberof_cache_corruption is failing with the following error:

E         ldap.BUSY: {'msgtype': 109, 'msgid': 12, 'result': 51, 'desc': 'Server is busy', 'ctrls': [], 'info': 'target entry busy because of a canceled operation'}

/usr/local/lib64/python3.9/site-packages/ldap/ldapobject.py:128: BUSY

This looks to be due to the server still processing the first group.rename() call, which is meant to fail with an ldap.OBJECT_CLASS_VIOLATION exception, as the second group.rename() call is sent in.
I mitigated this on the test environment with a time.sleep(2), but there should be a better way to fix this. Will keep looking.

Package Version and Platform:

  • Platform: RHEL 9
  • Package and version: Multiple builds, but I found it on 389-ds-base-2.4.5-12.el9_4

Steps to Reproduce
Steps to reproduce the behavior:

  1. Run the regression test on a RHEL9 test VM. The test is failing on the main branch currently.
  2. The test will fail.

Expected results
The test passes, assuming the build used doesn't cause the test to fail in other ways.

Additional context
I haven't seen this issue documented elsewhere, so I'm opening it here for reference while I investigate further.

Activity

  1. abeisemb commented on Feb 12, 2025

    @abeisemb
    CollaboratorAuthor

    It seems to me that the best way to resolve this is to force a wait until the standalone topology is "free", so to speak. Python is synchronous by default, so I don't think splitting the function into threads would solve the root cause: the first group.rename() call is finished by the time the second one is called, but the server isn't ready.
    Hopefully there's a lib389 function or method to ensure the standalone topology isn't busy. Otherwise, I'll probably have to go with the time.sleep() solution. The main solutions I see in dirsrvtests for issues involving time are to sleep, wait, or start threads.

  2. progier389 commented on Feb 13, 2025

    @progier389
    Contributor

    FYI:
    The server seldom returns LDAP_BUSY:
    It happens when there are too many retries (txn lock conflict) or a conflict in the entry cache after an aborted transaction
    As the scenario stress testys the aborted transaction case, sometime getting LDAP_BUSY looks normal.

    The usual way to handle LDAP_BUSY (if it is not a bug on the server side) is to wait a bit then retry the operation in a loop: i,e:
    retry_if_busy(lambda : managed_entry_user_conn.rename("cn=modrdn group"))

    def retry_if_busy(f):
    while True:
    try:
    return f()
    except ldap.LDAP_BUSY:
    time.sleep(0.02)

  3. abeisemb commented on Feb 14, 2025

    @abeisemb
    CollaboratorAuthor

    I see, thanks for the advice. In all my runs, this test has returned LDAP_BUSY on the 1minutetip machines without intervention i.e. sleep(2), but this method seems more flexible and better suited to solve the actual issue.

  4. abeisemb commented on Feb 17, 2025

    @abeisemb
    CollaboratorAuthor

    Curiously, this solution causes the entire standalone topology to go down on RHEL 9 machines. Barring a significant misconfiguration on my part, I think this has to do with an interaction involving the group.rename() exception being caught in the try except block, and then rerunning group.rename() after the exception is caught. This can be in the while loop, or simply having another rename() call after the except block. Sleeping for longer doesn't seem to make a difference (I tried up to 120 seconds).
    The exact same code block causes the test to succeed on RHEL 8 machines; I checked for differences in the group.rename() definition between branches, but I haven't found anything yet. It may be some difference in RHEL itself, or a consequence of larger differences between 389-ds-base branches.

  5. progier389 commented on Feb 18, 2025

    @progier389
    Contributor

    this solution causes the entire standalone topology to go down

    Can you precise ?
    Is ns-slapd crashing (i.e generating a core) ?
    in this case coredumpctl debug should help to see the crashing stack
    Or is is doing a shutdown ? In this cased there should be some messages in the error log

  6. abeisemb commented on Feb 18, 2025

    @abeisemb
    CollaboratorAuthor

    Can you precise ? Is ns-slapd crashing (i.e generating a core) ? in this case coredumpctl debug should help to see the crashing stack Or is is doing a shutdown ? In this cased there should be some messages in the error log

    There looks to be a coredump caused by ns-slapd. First, py.test returns the error ldap.SERVER_DOWN: {'result': -1, 'desc': "Can't contact LDAP server", 'errno': 104, 'ctrls': [], 'info': 'target entry busy because of a canceled operation'}.
    There is also an error log from the topology used in the test:
    ------------------ Extract of instance standalone1 error log -------------------
    [18/Feb/2025:09:11:57.565847243 -0500] - ERR - oc_check_allowed_sv - Entry "uid=testuser,ou=People,dc=example,dc=com" -- attribute "memberOf" not allowed
    [18/Feb/2025:09:11:57.569440480 -0500] - ERR - oc_check_allowed_sv - Entry "uid=testuser,ou=People,dc=example,dc=com" -- attribute "memberOf" not allowed
    [18/Feb/2025:09:11:57.570851725 -0500] - ERR - memberof-plugin - memberof_postop_modrdn - Update failed for (cn=group,ou=Groups,dc=example,dc=com), error (65)

    Finally, coredumpctl debug shows a generated core:
    Core was generated by `/usr/sbin/ns-slapd -D /etc/dirsrv/slapd-standalone1 -i /run/dirsrv/slapd-standa'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0x00007f74fdb97e48 in backentry_get_ndn (e=e@entry=0x0) at ldap/servers/slapd/back-ldbm/backentry.c:99
    99 return (char *)slapi_sdn_get_ndn(slapi_entry_get_sdn_const(e->ep_entry));
    [Current thread is 1 (Thread 0x7f70ea9ef640 (LWP 16170))]

    The test run also returned a full stack trace I can share if necessary.

    Backtracing in coredumpctl debug leads me to backentry_get_ndn (e=e@entry=0x0) at ldap/servers/slapd/back-ldbm/backentry.c:99. Might be relevant, will continue investigating.

  7. progier389 commented on Feb 18, 2025

    @progier389
    Contributor

    Interesting!
    FYI:
    I do not reproduce the issue on Fedora with main but I reproduce it on latyest RHEL 9 build :
    RHEL-9.6.0-20250210.2: with 389-ds-base-2.6.1-2.el9

    #0  0x00007fe95eeb9e48 in backentry_get_ndn () at /usr/lib64/dirsrv/plugins/libback-ldbm.so
    #1  0x00007fe95eec4707 in id2entry_add_ext () at /usr/lib64/dirsrv/plugins/libback-ldbm.so
    #2  0x00007fe95eeeb20e in modify_update_all () at /usr/lib64/dirsrv/plugins/libback-ldbm.so
    #3  0x00007fe95eeee762 in ldbm_back_modrdn () at /usr/lib64/dirsrv/plugins/libback-ldbm.so
    #4  0x00007fe96398221a in op_shared_rename.constprop () at /usr/lib64/dirsrv/libslapd.so.0
    #5  0x00007fe963928b0c in do_modrdn () at /usr/lib64/dirsrv/libslapd.so.0
    #6  0x0000559bfcb3ec3c in connection_threadmain ()
    #7  0x00007fe963f34c34 in _pt_root () at /lib64/libnspr4.so
    #8  0x00007fe96348a3b2 in start_thread () at /lib64/libc.so.6
    #9  0x00007fe96350f430 in clone3 () at /lib64/libc.so.6
    

    So we have clearly a problem on RHEL-9

  8. abeisemb commented on Feb 18, 2025

    @abeisemb
    CollaboratorAuthor

    Didn't reproduce this issue on RHEL-10 beta either using the latest RHEL 10 build (389-ds-base-3.0.6-2.el10.x86_64). Looks to be specific to RHEL 9.

  9. progier389 commented on Feb 19, 2025

    @progier389
    Contributor
  10. gudtanha commented on Feb 28, 2025

    @gudtanha

    Traiged: https://issues.redhat.com/browse/IDMDS-5288

    Neither of my subscriptions is allowed to view the content.
    Not a problem generally - can't contribute much anyways.

    BUT: Please fix this bug - whatever the reason for it may be :-) Please share a solution/workaround (perferably with explanation) as soon as possible.

    We migrated from rock solid 1.3.10 CentOS7 to RHEL9 and every >1.4 version crashes and/or soft-locks in the memberOf plugin.
    We couldn't manage to get any reliable 389-ds service on RHEL9, no matter if we take the distribution package or our own build (tested almost all branches - currently tracking 2.5).

    Any progress on this (crashes on RHEL9, probably related to spurious and unexplainable server-busy logs) highly appreciated!
    Thansk a lot in advance!

  11. vashirov commented on Feb 28, 2025

    @vashirov
    Member

    @gudtanha this is a link to an internal project, it shouldn't be here in the first place, sorry.

    I see you opened #6393, but it lacks information how to reproduce the issue, logs or any information about crashes.

    If you have a RHEL/RHDS subscription with support, please open a support case. Support will help you to gather debug information, and it will allow us to prioritize work on your issue.

  12. gudtanha commented on Feb 28, 2025

    @gudtanha

    We migrated from rock solid 1.3.10 CentOS7 to RHEL9 and every >1.4 version crashes and/or soft-locks in the memberOf plugin. We couldn't manage to get any reliable 389-ds service on RHEL9, no matter if we take the distribution package or our own build (tested almost all branches - currently tracking 2.5).

    Here's one example of one of our self-destroying instances - it happens after a few days of operation as single-supplier with 6 consumers:

           PID: 3377240 (ns-slapd)
           UID: 389 (dirsrv)
           GID: 389 (dirsrv)
        Signal: 11 (SEGV)
     Timestamp: Fri 2025-02-28 12:43:47 CET (8min ago)
    

    Command Line: /usr/sbin/ns-slapd -D /etc/dirsrv/slapd-comdir -i /run/dirsrv/slapd-comdir.pid
    Executable: /usr/sbin/ns-slapd
    Control Group: /system.slice/system-dirsrv.slice/dirsrv@comdir.service
    Unit: dirsrv@comdir.service
    Slice: system-dirsrv.slice
    Boot ID:
    Machine ID:
    Hostname:
    Storage: /var/lib/systemd/coredump/core.ns-slapd.389.b1c1a263ed484c30b65589320abc8ff2.3377240.1740743027000000.zst (present)
    Size on Disk: 70.3M
    Message: Process 3377240 (ns-slapd) of user 389 dumped core.

                Stack trace of thread 3377281:
                #0  0x00007fd1b06d0404 attr_get_deletion_csn (libslapd.so.0 + 0xd0404)
                #1  0x00007fd1abf01df1 entry_get_rdn_mods (libback-ldbm.so + 0x7adf1)
                #2  0x00007fd1abf046d7 ldbm_back_modify (libback-ldbm.so + 0x7d6d7)
                #3  0x00007fd1b072a7f6 op_shared_modify (libslapd.so.0 + 0x12a7f6)
                #4  0x00007fd1b072b46d do_modify (libslapd.so.0 + 0x12b46d)
                #5  0x00005648c6864c08 connection_threadmain (ns-slapd + 0x1ec08)
                #6  0x00007fd1b0db2c34 _pt_root (libnspr4.so + 0x2cc34)
                #7  0x00007fd1b0289d22 start_thread (libc.so.6 + 0x89d22)
                #8  0x00007fd1b030ed40 __clone3 (libc.so.6 + 0x10ed40)
    
                Stack trace of thread 3377240:
                #0  0x00007fd1b02d4175 clock_nanosleep@GLIBC_2.2.5 (libc.so.6 + 0xd4175)
                #1  0x00007fd1b02d8d87 __nanosleep (libc.so.6 + 0xd8d87)
                #2  0x00007fd1b0304c29 usleep (libc.so.6 + 0x104c29)
                #3  0x00005648c6867a2a slapd_daemon (ns-slapd + 0x21a2a)
                #4  0x00005648c685b7be main (ns-slapd + 0x157be)
                #5  0x00007fd1b02295d0 __libc_start_call_main (libc.so.6 + 0x295d0)
                #6  0x00007fd1b0229680 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x29680)
                #7  0x00005648c685ca85 _start (ns-slapd + 0x16a85)
    
                Stack trace of thread 3377249:
                #0  0x00007fd1b030432d __select (libc.so.6 + 0x10432d)
                #1  0x00007fd1b076f664 DS_Sleep (libslapd.so.0 + 0x16f664)
                #2  0x00007fd1abf20b4f bdb_trickle_threadmain (libback-ldbm.so + 0x99b4f)
                #3  0x00007fd1b0db2c34 _pt_root (libnspr4.so + 0x2cc34)
                #4  0x00007fd1b0289d22 start_thread (libc.so.6 + 0x89d22)
                #5  0x00007fd1b030ed40 __clone3 (libc.so.6 + 0x10ed40)
    
                Stack trace of thread 3377251:
                #0  0x00007fd1b030432d __select (libc.so.6 + 0x10432d)
                #1  0x00007fd1b076f664 DS_Sleep (libslapd.so.0 + 0x16f664)
                #2  0x00007fd1abf207cf bdb_locks_monitoring_threadmain (libback-ldbm.so + 0x997cf)
                #3  0x00007fd1b0db2c34 _pt_root (libnspr4.so + 0x2cc34)
                #4  0x00007fd1b0289d22 start_thread (libc.so.6 + 0x89d22)
                #5  0x00007fd1b030ed40 __clone3 (libc.so.6 + 0x10ed40)
    

    Only solution is to create the supplier instance from scratch along with all consumers...
    Any fix candidate welcome, will test!

  13. vashirov commented on Feb 28, 2025

    @vashirov
    Member

    @gudtanha please open a separate ticket, this is unrelated to the current issue.
    And also provide more detailed steps to reproduce the crash. Stack trace alone is not helpful, unless we know the reproducer.

  14. progier389 commented on Mar 27, 2025

    @progier389
    Contributor

    @abeisemb FYI: now that the crash fix has been pushed upstream nothing prevents you to go ahead and fix the test_betxn_modrdn_memberof_cache_corruption testcase as planned ...

  15. abeisemb commented on Mar 27, 2025

    @abeisemb
    CollaboratorAuthor

    Acknowledged, I'll submit an MR in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions