]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10047 back-mdb: delete idxckp table after slapindex
authorHoward Chu <hyc@openldap.org>
Tue, 9 May 2023 13:36:25 +0000 (14:36 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 15 May 2023 19:21:44 +0000 (19:21 +0000)
Could do it when beginning too, either way an interrupted slapindex
must be rerun completely.

servers/slapd/back-mdb/tools.c

index 2ef94b16f20a0bbd8aeb2f6f1b648531d3831130..3a468b283e2eb9fae19cfbed63523b8664179061 100644 (file)
@@ -58,6 +58,8 @@ static MDB_cursor *mcp = NULL, *mcd = NULL;
 static MDB_val key, data;
 static ID previd = NOID;
 
+static int reindexing;
+
 typedef struct dn_id {
        ID id;
        struct berval dn;
@@ -223,6 +225,20 @@ int mdb_tool_entry_close(
                }
                mdb_tool_txn = NULL;
        }
+       if( reindexing ) {
+               struct mdb_info *mdb = be->be_private;
+               if ( !txi ) {
+                       int rc = mdb_txn_begin( mdb->mi_dbenv, NULL, 0, &txi );
+                       if( rc != 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "=> " LDAP_XSTRING(mdb_tool_entry_close) ": database %s: "
+                                       "txn_begin failed: %s (%d)\n",
+                                       be->be_suffix[0].bv_val, mdb_strerror(rc), rc );
+                               return -1;
+                       }
+               }
+               mdb_drop( txi, mdb->mi_idxckp, 0 );
+       }
        if( txi ) {
                int rc;
                if (( rc = mdb_txn_commit( txi ))) {
@@ -841,6 +857,8 @@ int mdb_tool_entry_reindex(
                return 0;
        }
 
+       reindexing = 1;
+
        /* Check for explicit list of attrs to index */
        if ( adv ) {
                int i, j, n;