Browse Source

Trac Ticket #290 - server hangs during shutdown if betxn pre/post op fails

https://fedorahosted.org/389/ticket/290

Fix description: The logic to call dblayer_txn_abort in the
ldbm_back update functions was wrong.  If the operations fail,
the abort function has to be called if dblayer_txn_begin is
already called and dblayer_txn_commit is not.  This patch
checks the txn value set by dblayer_txn_commit to determine
to call dblayer_txn_abort or not.
Noriko Hosoi 13 years ago
parent
commit
4495cf3333

+ 2 - 2
ldap/servers/slapd/back-ldbm/ldbm_add.c

@@ -667,7 +667,7 @@ ldbm_back_add( Slapi_PBlock *pb )
 	 */
 	txn.back_txn_txn = NULL; /* ready to create the child transaction */
 	for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++) {
-		if (retry_count > 0) {
+		if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 			dblayer_txn_abort(li,&txn);
 			/* txn is no longer valid - reset slapi_txn to the parent */
 			txn.back_txn_txn = NULL;
@@ -976,7 +976,7 @@ diskfull_return:
 		rc= return_on_disk_full(li);
 	} else {
 		/* It is safer not to abort when the transaction is not started. */
-		if (retry_count > 0) {
+		if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 			dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */
 			/* txn is no longer valid - reset the txn pointer to the parent */
 			txn.back_txn_txn = NULL;

+ 2 - 2
ldap/servers/slapd/back-ldbm/ldbm_delete.c

@@ -460,7 +460,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
 	
 	txn.back_txn_txn = NULL; /* ready to create the child transaction */
 	for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++) {
-		if (retry_count > 0) {
+		if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 			dblayer_txn_abort(li,&txn);
 			/* We're re-trying */
 			LDAPDebug( LDAP_DEBUG_TRACE, "Delete Retrying Transaction\n", 0, 0, 0 );
@@ -987,7 +987,7 @@ error_return:
 	    rc= SLAPI_FAIL_GENERAL;
 
 	/* It is safer not to abort when the transaction is not started. */
-	if (retry_count > 0) {
+	if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 		dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */
 		/* txn is no longer valid - reset the txn pointer to the parent */
 		txn.back_txn_txn = NULL;

+ 3 - 3
ldap/servers/slapd/back-ldbm/ldbm_modify.c

@@ -414,7 +414,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
 	txn.back_txn_txn = NULL; /* ready to create the child transaction */
 	for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++) {
 
-		if (retry_count > 0) {
+		if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 			dblayer_txn_abort(li,&txn);
 			/* txn is no longer valid - reset slapi_txn to the parent */
 			txn.back_txn_txn = NULL;
@@ -614,8 +614,8 @@ error_return:
 
 	if (disk_full) {
 	    rc= return_on_disk_full(li);
-	} else if (ldap_result_code != LDAP_SUCCESS) {
-		if (retry_count > 0) {
+	} else {
+		if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
 			/* It is safer not to abort when the transaction is not started. */
 			dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */
 			/* txn is no longer valid - reset the txn pointer to the parent */

+ 3 - 2
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c

@@ -701,7 +701,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
     txn.back_txn_txn = NULL; /* ready to create the child transaction */
     for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++)
     {
-        if (retry_count > 0)
+        if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn))
         {
             dblayer_txn_abort(li,&txn);
             /* txn is no longer valid - reset slapi_txn to the parent */
@@ -1072,7 +1072,8 @@ error_return:
     else 
     {
         /* It is safer not to abort when the transaction is not started. */
-        if (retry_count > 0) {
+        if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn))
+        {
             dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */
             /* txn is no longer valid - reset the txn pointer to the parent */
             txn.back_txn_txn = NULL;