Browse Source

Resolves: 238630
Summary: Remove changelog db file when replica config is removed.

Nathan Kinder 18 years ago
parent
commit
ad8f641725

+ 13 - 9
ldap/servers/plugins/replication/cl5_api.c

@@ -6391,20 +6391,24 @@ static void _cl5DBCloseFile (void **data)
 		_cl5WriteRUV (file, PR_FALSE); 
 	}
 
-	/* close file */
+	/* close the db */
 	if (file->db)
 	    file->db->close(file->db, 0);
 
 	if (file->flags & DB_FILE_DELETED)
-    {
-        PR_snprintf(fullpathname, MAXPATHLEN, "%s/%s", s_cl5Desc.dbDir, file->name);
-	    if (PR_Delete(fullpathname) != PR_SUCCESS)	
+        {
+            int rc = 0;
+            /* We need to use the libdb API to delete the files, otherwise we'll
+             * run into problems when we try to checkpoint transactions later. */
+            PR_snprintf(fullpathname, MAXPATHLEN, "%s/%s", s_cl5Desc.dbDir, file->name);
+            rc = s_cl5Desc.dbEnv->dbremove(s_cl5Desc.dbEnv, 0, fullpathname, 0, 0);
+            if (rc != 0)
 	    {
-		    slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5DBCloseFile: "
-                  "failed to remove (%s) file; NSPR error - %d\n", file->name, PR_GetError ());
-
-	    }
-    }
+                slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5DBCloseFile: "
+                    "failed to remove (%s) file; libdb error - %d (%s)\n", file->name,
+                    rc, dblayer_strerror(rc));
+            }
+        }
 
 	/* slapi_ch_free accepts NULL pointer */
 	slapi_ch_free ((void**)&file->name);

+ 8 - 0
ldap/servers/plugins/replication/repl5_replica_config.c

@@ -460,9 +460,17 @@ replica_config_delete (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter
 
     if (mtnode_ext->replica)
     {
+        char ebuf[BUFSIZ];
+
         /* remove object from the hash */
         r = (Replica*)object_get_data (mtnode_ext->replica);
         PR_ASSERT (r);
+        /* The changelog for this replica is no longer valid, so we should remove it. */
+        slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_delete: "
+                        "Warning: The changelog for replica %s is no longer valid since "
+                        "the replica config is being deleted.  Removing the changelog.\n",
+                        escape_string(slapi_sdn_get_dn(replica_get_root(r)),ebuf));
+        cl5DeleteDBSync(mtnode_ext->replica);
         replica_delete_by_name (replica_get_name (r));
         object_release (mtnode_ext->replica);
         mtnode_ext->replica = NULL;