summaryrefslogtreecommitdiffstats
path: root/ldap/servers
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2009-08-06 13:16:01 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2009-08-06 13:16:01 -0700
commita26ba73fb5040383c27872997bc07ab0c2006459 (patch)
treec68d03fd60f5a46456019ceeecc64217f7467283 /ldap/servers
parent0565e8c39894b059191cfaff2176f758141ffe3b (diff)
downloadds-a26ba73fb5040383c27872997bc07ab0c2006459.tar.gz
ds-a26ba73fb5040383c27872997bc07ab0c2006459.tar.xz
ds-a26ba73fb5040383c27872997bc07ab0c2006459.zip
509472 db2index all does not reindex all the db backends correctly
db2index all (internally, called upgradedb) reads through the main db id2entry.db# and reindex all the associated indexed attributes. The reindex borrows the import code where the entry id is newly assigned. The new entry id's are connective. On the other hand, entry id's of the entries in the db to be reindexed are not. The borrowed import code assumes the entry id and the index of the fifo are tightly coupled and the timing when the writing to and reading from the fifo are calculated based upon the assumption. The assumption should have been revised so that the entry id which is available up to is kept in ready_EID in the job structure and entry id from each entry (entry->ep_id) is compared with ready_EID instead of ready_ID that holds the sequential number. Additionally, I eliminated unused variable "shift" from import_fifo_fetch. Also, _dblayer_delete_instance_dir cleans up files and directories, recursively.
Diffstat (limited to 'ldap/servers')
-rw-r--r--ldap/servers/slapd/back-ldbm/dblayer.c2
-rw-r--r--ldap/servers/slapd/back-ldbm/import-threads.c37
-rw-r--r--ldap/servers/slapd/back-ldbm/import.c15
-rw-r--r--ldap/servers/slapd/back-ldbm/import.h3
4 files changed, 31 insertions, 26 deletions
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 42642b24..7cf407c4 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4324,7 +4324,7 @@ static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb)
}
else
{
- rval = PR_Delete(filename);
+ rval = ldbm_delete_dirs(filename);
}
}
PR_CloseDir(dirhandle);
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index b5e4e07f..1e07147d 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -651,11 +651,11 @@ void import_producer(void *param)
old_ep = job->fifo.item[idx].entry;
if (old_ep) {
/* for the slot to be recycled, it needs to be already absorbed
- * by the foreman (id >= ready_ID), and all the workers need to
+ * by the foreman (id >= ready_EID), and all the workers need to
* be finished with it (refcount = 0).
*/
while (((old_ep->ep_refcnt > 0) ||
- (old_ep->ep_id >= job->ready_ID))
+ (old_ep->ep_id >= job->ready_EID))
&& (info->command != ABORT) && !(job->flags & FLAG_ABORT)) {
info->state = WAITING;
DS_Sleep(sleeptime);
@@ -887,11 +887,11 @@ void index_producer(void *param)
old_ep = job->fifo.item[idx].entry;
if (old_ep) {
/* for the slot to be recycled, it needs to be already absorbed
- * by the foreman (id >= ready_ID), and all the workers need to
+ * by the foreman (id >= ready_EID), and all the workers need to
* be finished with it (refcount = 0).
*/
while (((old_ep->ep_refcnt > 0) ||
- (old_ep->ep_id >= job->ready_ID))
+ (old_ep->ep_id >= job->ready_EID))
&& (info->command != ABORT) && !(job->flags & FLAG_ABORT)) {
info->state = WAITING;
DS_Sleep(sleeptime);
@@ -980,7 +980,7 @@ import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize)
for ( i = 0, slot_found = 0 ; i < job->fifo.size ; i++ ) {
temp_ep = job->fifo.item[i].entry;
if (temp_ep) {
- if (temp_ep->ep_refcnt == 0 && temp_ep->ep_id <= job->ready_ID) {
+ if (temp_ep->ep_refcnt == 0 && temp_ep->ep_id <= job->ready_EID) {
job->fifo.item[i].entry = NULL;
if (job->fifo.c_bsize > job->fifo.item[i].esize)
job->fifo.c_bsize -= job->fifo.item[i].esize;
@@ -1094,7 +1094,6 @@ void import_foreman(void *param)
int ret = 0;
struct attrinfo *parentid_ai;
Slapi_PBlock *pb = slapi_pblock_new();
- int shift = 0;
PR_ASSERT(info != NULL);
PR_ASSERT(inst != NULL);
@@ -1136,10 +1135,13 @@ void import_foreman(void *param)
info->state = RUNNING;
/* Read that entry from the cache */
- fi = import_fifo_fetch(job, id, 0, shift);
- if (! fi) {
+ fi = import_fifo_fetch(job, id, 0);
+ if (NULL == fi) {
import_log_notice(job, "WARNING: entry id %d is missing", id);
- shift++;
+ continue;
+ }
+ if (NULL == fi->entry) {
+ import_log_notice(job, "WARNING: entry for id %d is missing", id);
continue;
}
@@ -1249,17 +1251,20 @@ void import_foreman(void *param)
}
- /* Remove the entry from the cache (caused by id2entry_add) */
- if (!(job->flags & FLAG_REINDEXING))/* reindex reads data from id2entry */
- cache_remove(&inst->inst_cache, fi->entry);
+ /* Remove the entry from the cache (Put in the cache in id2entry_add) */
+ if (!(job->flags & FLAG_REINDEXING)) {
+ /* reindex reads data from id2entry */
+ cache_remove(&inst->inst_cache, fi->entry);
+ }
fi->entry->ep_refcnt = job->number_indexers;
- cont:
+cont:
if (job->flags & FLAG_ABORT) {
goto error;
}
job->ready_ID = id;
+ job->ready_EID = fi->entry->ep_id;
info->last_ID_processed = id;
id++;
@@ -1377,7 +1382,7 @@ void import_worker(void *param)
info->state = RUNNING;
/* Read that entry from the cache */
- fi = import_fifo_fetch(job, id, 1, 0);
+ fi = import_fifo_fetch(job, id, 1);
ep = fi ? fi->entry : NULL;
if (!ep) {
/* skipping an entry that turned out to be bad */
@@ -1706,9 +1711,9 @@ static int bulk_import_queue(ImportJob *job, Slapi_Entry *entry)
/* the producer could be running thru the fifo while
* everyone else is cycling to a new pass...
- * double-check that this entry is < ready_ID
+ * double-check that this entry is < ready_EID
*/
- while ((old_ep->ep_id >= job->ready_ID) && !(job->flags & FLAG_ABORT))
+ while ((old_ep->ep_id >= job->ready_EID) && !(job->flags & FLAG_ABORT))
{
DS_Sleep(PR_MillisecondsToInterval(import_sleep_time));
}
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index 48e19c81..8c334d43 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -95,23 +95,22 @@ static int import_fifo_init(ImportJob *job)
return 0;
}
-FifoItem *import_fifo_fetch(ImportJob *job, ID id, int worker, int shift)
+FifoItem *import_fifo_fetch(ImportJob *job, ID id, int worker)
{
int idx = id % job->fifo.size;
FifoItem *fi;
if (job->fifo.item) {
- fi = &(job->fifo.item[idx]);
+ fi = &(job->fifo.item[idx]);
} else {
- return NULL;
+ return NULL;
}
if (fi->entry) {
- if (id != fi->entry->ep_id - shift)
- fi = NULL;
- else if (worker) {
- if (fi->bad) return NULL;
- PR_ASSERT(fi->entry->ep_refcnt > 0);
+ if (worker && fi->bad) {
+ import_log_notice(job, "WARNING: bad entry: ID %d", id);
+ return NULL;
}
+ PR_ASSERT(fi->entry->ep_refcnt > 0);
}
return fi;
}
diff --git a/ldap/servers/slapd/back-ldbm/import.h b/ldap/servers/slapd/back-ldbm/import.h
index 0ae56c1d..aa3201ce 100644
--- a/ldap/servers/slapd/back-ldbm/import.h
+++ b/ldap/servers/slapd/back-ldbm/import.h
@@ -124,6 +124,7 @@ typedef struct {
ID first_ID; /* Import pass starts at this ID */
ID lead_ID; /* Highest ID available in the cache */
ID ready_ID; /* Highest ID the foreman is done with */
+ ID ready_EID; /* Highest Entry ID the foreman is done with */
ID trailing_ID; /* Lowest ID still available in the cache */
int current_pass; /* un-merged pass number in a multi-pass import */
int total_pass; /* total pass number in a multi-pass import */
@@ -204,7 +205,7 @@ struct _import_worker_info {
/* import.c */
-FifoItem *import_fifo_fetch(ImportJob *job, ID id, int worker, int shift);
+FifoItem *import_fifo_fetch(ImportJob *job, ID id, int worker);
void import_free_job(ImportJob *job);
void import_log_notice(ImportJob *job, char *format, ...)
#ifdef __GNUC__