Skip to content
Snippets Groups Projects
Commit d1376d47 authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#8360 fix ad info after failed txn

If an add or modify op referenced a previously unused attrtype,
the mi_ads/mi_numads would be incremented to include it. If the
op fails to commit, these additions must also be reverted.
parent 93619386
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ mdb_add(Operation *op, SlapReply *rs ) ...@@ -37,6 +37,7 @@ mdb_add(Operation *op, SlapReply *rs )
ID eid, pid = 0; ID eid, pid = 0;
mdb_op_info opinfo = {{{ 0 }}}, *moi = &opinfo; mdb_op_info opinfo = {{{ 0 }}}, *moi = &opinfo;
int subentry; int subentry;
int numads = mdb->mi_numads;
int success; int success;
...@@ -401,6 +402,7 @@ txnReturn: ...@@ -401,6 +402,7 @@ txnReturn:
LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next );
opinfo.moi_oe.oe_key = NULL; opinfo.moi_oe.oe_key = NULL;
if ( op->o_noop ) { if ( op->o_noop ) {
mdb->mi_numads = numads;
mdb_txn_abort( txn ); mdb_txn_abort( txn );
rs->sr_err = LDAP_X_NO_OPERATION; rs->sr_err = LDAP_X_NO_OPERATION;
txn = NULL; txn = NULL;
...@@ -410,6 +412,7 @@ txnReturn: ...@@ -410,6 +412,7 @@ txnReturn:
rs->sr_err = mdb_txn_commit( txn ); rs->sr_err = mdb_txn_commit( txn );
txn = NULL; txn = NULL;
if ( rs->sr_err != 0 ) { if ( rs->sr_err != 0 ) {
mdb->mi_numads = numads;
rs->sr_text = "txn_commit failed"; rs->sr_text = "txn_commit failed";
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(mdb_add) ": %s : %s (%d)\n", LDAP_XSTRING(mdb_add) ": %s : %s (%d)\n",
...@@ -433,6 +436,7 @@ return_results: ...@@ -433,6 +436,7 @@ return_results:
if( moi == &opinfo ) { if( moi == &opinfo ) {
if( txn != NULL ) { if( txn != NULL ) {
mdb->mi_numads = numads;
mdb_txn_abort( txn ); mdb_txn_abort( txn );
} }
if ( opinfo.moi_oe.oe_key ) { if ( opinfo.moi_oe.oe_key ) {
......
...@@ -458,6 +458,7 @@ mdb_modify( Operation *op, SlapReply *rs ) ...@@ -458,6 +458,7 @@ mdb_modify( Operation *op, SlapReply *rs )
LDAPControl **postread_ctrl = NULL; LDAPControl **postread_ctrl = NULL;
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS]; LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
int num_ctrls = 0; int num_ctrls = 0;
int numads = mdb->mi_numads;
#ifdef LDAP_X_TXN #ifdef LDAP_X_TXN
int settle = 0; int settle = 0;
...@@ -667,12 +668,15 @@ txnReturn: ...@@ -667,12 +668,15 @@ txnReturn:
LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next );
opinfo.moi_oe.oe_key = NULL; opinfo.moi_oe.oe_key = NULL;
if( op->o_noop ) { if( op->o_noop ) {
mdb->mi_numads = numads;
mdb_txn_abort( txn ); mdb_txn_abort( txn );
rs->sr_err = LDAP_X_NO_OPERATION; rs->sr_err = LDAP_X_NO_OPERATION;
txn = NULL; txn = NULL;
goto return_results; goto return_results;
} else { } else {
rs->sr_err = mdb_txn_commit( txn ); rs->sr_err = mdb_txn_commit( txn );
if ( rs->sr_err )
mdb->mi_numads = numads;
txn = NULL; txn = NULL;
} }
} }
...@@ -715,6 +719,7 @@ done: ...@@ -715,6 +719,7 @@ done:
if( moi == &opinfo ) { if( moi == &opinfo ) {
if( txn != NULL ) { if( txn != NULL ) {
mdb->mi_numads = numads;
mdb_txn_abort( txn ); mdb_txn_abort( txn );
} }
if ( opinfo.moi_oe.oe_key ) { if ( opinfo.moi_oe.oe_key ) {
......
...@@ -713,6 +713,7 @@ done: ...@@ -713,6 +713,7 @@ done:
mdb_tool_txn = NULL; mdb_tool_txn = NULL;
idcursor = NULL; idcursor = NULL;
if( rc != 0 ) { if( rc != 0 ) {
mdb->mi_numads = 0;
snprintf( text->bv_val, text->bv_len, snprintf( text->bv_val, text->bv_len,
"txn_commit failed: %s (%d)", "txn_commit failed: %s (%d)",
mdb_strerror(rc), rc ); mdb_strerror(rc), rc );
...@@ -983,6 +984,7 @@ done: ...@@ -983,6 +984,7 @@ done:
if( rc == 0 ) { if( rc == 0 ) {
rc = mdb_txn_commit( mdb_tool_txn ); rc = mdb_txn_commit( mdb_tool_txn );
if( rc != 0 ) { if( rc != 0 ) {
mdb->mi_numads = 0;
snprintf( text->bv_val, text->bv_len, snprintf( text->bv_val, text->bv_len,
"txn_commit failed: %s (%d)", "txn_commit failed: %s (%d)",
mdb_strerror(rc), rc ); mdb_strerror(rc), rc );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment