ldap/servers/slapd/back-ldbm/dblayer.c | 5 +++--
ldap/servers/slapd/back-ldbm/ldbm_instance_config.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 1d5859fdf332594b37c6ab072e2657435e1958d1
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 3 11:48:23 2010 -0700
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.
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c
b/ldap/servers/slapd/back-ldbm/dblayer.c
index 1254b37..27a4f6f 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -3128,7 +3128,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
@@ -3139,7 +3139,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 a826e3c..dc71f8c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -1084,7 +1084,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);