]> git.sur5r.net Git - openldap/commitdiff
Fix attribute/group to allow TXN to abort on lock failure. Save and
authorHoward Chu <hyc@openldap.org>
Wed, 26 Feb 2003 12:09:10 +0000 (12:09 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 26 Feb 2003 12:09:10 +0000 (12:09 +0000)
restore op->o_do_not_cache on TXN retry, bdb_group will set it if it
fails to get a lock.

servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/attribute.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/group.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c

index 3e85b1a7ad04343114f135f79f7bdbb99f916e54..20aa3193dbac9f06e4bf4d8f33c1ed1e79b199b3 100644 (file)
@@ -99,6 +99,7 @@ retry:        /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -134,6 +135,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
        
        /*
index a98a16fa85656768fcccc183819f31a755af700b..f5cbdf7577a693ecd4900d8ec6fd8c3332e6c71b 100644 (file)
@@ -104,6 +104,12 @@ dn2entry_retry:
                        break;
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
+                       /* the txn must abort and retry */
+                       if ( txn ) {
+                               boi->boi_err = rc;
+                               return LDAP_BUSY;
+                       }
+                       ldap_pvt_thread_yield();
                        goto dn2entry_retry;
                default:
                        boi->boi_err = rc;
index 5a28d25581beda00a009eaa534f845a1a21a0ffd..449d0f6d7339be00c4ffe52f27d155ff9349147c 100644 (file)
@@ -157,6 +157,7 @@ struct bdb_op_info {
        DB_TXN*         boi_txn;
        u_int32_t       boi_err;
        u_int32_t       boi_locker;
+       int             boi_acl_cache;
 };
 
 #define        DB_OPEN(db, file, name, type, flags, mode) \
index 79cb4608439ce6c7225257a4978302f433f978dd..3aff606e7136bb4f63898942f91b080f80b96bfa 100644 (file)
@@ -70,6 +70,7 @@ retry:        /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -106,6 +107,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        if ( !be_issuffix( be, ndn ) ) {
index 1df9e776ed18b83d1e50d48eb796f1b02c9b0062..4113eaa93687091dd6ecd00409ce0583b0126f82 100644 (file)
@@ -109,9 +109,19 @@ dn2entry_retry:
                /* can we find group entry */
                rc = bdb_dn2entry_r( be, txn, gr_ndn, &e, NULL, 0, locker, &lock ); 
                if( rc ) {
-                       if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED )
-                               goto dn2entry_retry;
                        boi->boi_err = rc;
+                       if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED ) {
+                               if ( txn ) {
+                               /* must let owning txn abort, but our result
+                                * is still inconclusive, so don't let it
+                                * get cached.
+                                */
+                                       op->o_do_not_cache = 1;
+                                       return( 1 );
+                               }
+                               ldap_pvt_thread_yield();
+                               goto dn2entry_retry;
+                       }
                        if ( free_lock_id ) {
                                LOCK_ID_FREE ( bdb->bi_dbenv, locker );
                        }
index a3b0846639f2198c735ce32e491af8f0f471c862..98fc5edd906d843f461ec4a87617419545986a6d 100644 (file)
@@ -319,6 +319,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -351,6 +352,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */
index 8fcba26ffd4b93f4c424d95b7229961761aa65d5..e3f054d1f576c48e3788c09be2b4a42ad127321c 100644 (file)
@@ -108,6 +108,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -141,6 +142,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */
@@ -276,6 +278,12 @@ retry:     /* transaction retry */
                rc = access_allowed( be, conn, op, p,
                        children, NULL, ACL_WRITE, NULL );
 
+               switch( opinfo.boi_err ) {
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto retry;
+               }
+
                if ( ! rc ) {
                        rc = LDAP_INSUFFICIENT_ACCESS;
 #ifdef NEW_LOGGING
@@ -326,6 +334,12 @@ retry:     /* transaction retry */
                                rc = access_allowed( be, conn, op, p,
                                        children, NULL, ACL_WRITE, NULL );
 
+                               switch( opinfo.boi_err ) {
+                               case DB_LOCK_DEADLOCK:
+                               case DB_LOCK_NOTGRANTED:
+                                       goto retry;
+                               }
+
                                p = NULL;
 
                                if ( ! rc ) {
@@ -467,6 +481,12 @@ retry:     /* transaction retry */
                        rc = access_allowed( be, conn, op, np, children,
                                NULL, ACL_WRITE, NULL );
 
+                       switch( opinfo.boi_err ) {
+                       case DB_LOCK_DEADLOCK:
+                       case DB_LOCK_NOTGRANTED:
+                               goto retry;
+                       }
+
                        if( ! rc ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG ( OPERATION, DETAIL1, 
@@ -528,6 +548,12 @@ retry:     /* transaction retry */
                                        rc = access_allowed( be, conn, op, np,
                                                children, NULL, ACL_WRITE, NULL );
 
+                                       switch( opinfo.boi_err ) {
+                                       case DB_LOCK_DEADLOCK:
+                                       case DB_LOCK_NOTGRANTED:
+                                               goto retry;
+                                       }
+
                                        np = NULL;
 
                                        if ( ! rc ) {
index 1e5818992c094dc873c3af50dcd1ae87c07d1acc..d258265e22c27eec1d66dc3d084aefeae2ff3b3d 100644 (file)
@@ -123,6 +123,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        *text = "internal error";
@@ -156,6 +157,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */