summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-06-03 11:48:23 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-06-03 11:48:23 -0700
commitbd35c4438a608266a8be7753a243506726de6606 (patch)
tree273505ace7437d1afeecb2225cf3d3da54a5f4fd
parent9efd0ba775b82174921e70706090a0cea5e9830a (diff)
downloadds-bd35c4438a608266a8be7753a243506726de6606.tar.gz
ds-bd35c4438a608266a8be7753a243506726de6606.tar.xz
ds-bd35c4438a608266a8be7753a243506726de6606.zip
597375 - Deleting LDBM database causes backup/restore problem
https://bugzilla.redhat.com/show_bug.cgi?id=597375 Fix Description: 1) When a backend was removed, the db instance directory was removed as well (See also 463774 - index files for database should be deleted when db is deleted). In case DB_RECOVER_FATAL is set in the DB open after the removal (e.g., in restore), the logs in the transaction logs are replayed and compared with the contents of the DB files. At that time, if the db instance directory does not exist, libdb returns FATAL error. To prevent the problem, we have to leave the empty directory. 2) When removing index files, we don't have to open index files with CREAT flag. Note: In the bug 463774, the server was fixed so that once a db backend is removed, the db instance directory is removed. With this fix (597375), the backend removal leaves the empty db instance directory. Plus, if backup is restored, even if the backup was made after the backend is deleted, the restore could create empty DB files in the deleted db instance directory if the transaction log files still contain the history of the deleted backend.
-rw-r--r--ldap/servers/slapd/back-ldbm/dblayer.c5
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_instance_config.c13
2 files changed, 15 insertions, 3 deletions
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index ae66be60..598b9976 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -3154,7 +3154,7 @@ int dblayer_erase_index_file_ex(backend *be, struct attrinfo *a,
int rc = 0;
DB *db = 0;
- if (NULL == pEnv) /* index file does not exist */
+ if (NULL == pEnv) /* db does not exist */
return rc;
/* Added for bug 600401. Somehow the checkpoint thread deadlocked on
@@ -3165,7 +3165,8 @@ int dblayer_erase_index_file_ex(backend *be, struct attrinfo *a,
dblayer_force_checkpoint(li);
}
- if (dblayer_get_index_file(be, a, &db, DBOPEN_CREATE) == 0) {
+ if (0 == dblayer_get_index_file(be, a, &db, 0 /* Don't create an index file
+ if it does not exist. */)) {
/* first, remove the file handle for this index, if we have it open */
PR_Lock(inst->inst_handle_list_mutex);
if (a->ai_dblayer) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index a6b11668..a33bb786 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -1109,7 +1109,18 @@ ldbm_instance_post_delete_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry*
}
PR_CloseDir(dirhandle);
}
- PR_RmDir(inst_dirp);
+ /*
+ * When a backend was removed, the db instance directory
+ * was removed as well (See also bz463774).
+ * In case DB_RECOVER_FATAL is set in the DB open after
+ * the removal (e.g., in restore), the logs in the transaction
+ * logs are replayed and compared with the contents of the DB
+ * files. At that time, if the db instance directory does not
+ * exist, libdb returns FATAL error. To prevent the problem,
+ * we have to leave the empty directory. (bz597375)
+ *
+ * PR_RmDir(inst_dirp);
+ */
} /* non-null dirhandle */
if (inst_dirp != inst_dir) {
slapi_ch_free_string(&inst_dirp);