|
|
ba46c7 |
From 2648c806841f09fe2ff130691b4a605feef7eb9b Mon Sep 17 00:00:00 2001
|
|
|
ba46c7 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
ba46c7 |
Date: Thu, 26 Sep 2013 09:18:11 -0700
|
|
|
ba46c7 |
Subject: [PATCH 18/28] Ticket #47523 - Set up replcation/agreement before initializing the sub suffix, the sub suffix is not found by ldapsearch
|
|
|
ba46c7 |
|
|
|
ba46c7 |
Bug description: If a replication is configured against a backend
|
|
|
ba46c7 |
before initializing the backend with a suffix entry, an RUV entry
|
|
|
ba46c7 |
is inserted first with the entryid 1. The RUV entry's entryrdn is
|
|
|
ba46c7 |
added to the entryrdn index with a suffix entry which is a parent
|
|
|
ba46c7 |
entry of the RUV entry having a temporary entryid 0, which was to
|
|
|
ba46c7 |
be replaced with the real entryid when the real suffix entry is
|
|
|
ba46c7 |
added. But the replacement code was not executed.
|
|
|
ba46c7 |
|
|
|
ba46c7 |
Fix description: When a real suffix is added to the entryrdn index,
|
|
|
ba46c7 |
it returns DB_KEYEXIST, which used to be ignored by resetting 0
|
|
|
ba46c7 |
(== SUCCESS). This patch returns DB_KEYEXIST to the caller and let
|
|
|
ba46c7 |
_entryrdn_insert_key use the info to replace the temporary entryid
|
|
|
ba46c7 |
with the real one. The error code is ignored by the other callers.
|
|
|
ba46c7 |
|
|
|
ba46c7 |
https://fedorahosted.org/389/ticket/47523
|
|
|
ba46c7 |
|
|
|
ba46c7 |
Reviewed by nkinder (Thanks!).
|
|
|
ba46c7 |
(cherry picked from commit e6eab21920a0374eb356da3d1f041312c6857ecd)
|
|
|
ba46c7 |
(cherry picked from commit 6b35dc7b04da023cc14045cc6dd1f5e304cf265f)
|
|
|
ba46c7 |
---
|
|
|
ba46c7 |
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 39 ++++++++++++++------------
|
|
|
ba46c7 |
1 files changed, 21 insertions(+), 18 deletions(-)
|
|
|
ba46c7 |
|
|
|
ba46c7 |
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
ba46c7 |
index 22940cc..d381166 100644
|
|
|
ba46c7 |
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
ba46c7 |
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
ba46c7 |
@@ -748,7 +748,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
ba46c7 |
renamedata.data = (void *)newelem;
|
|
|
ba46c7 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
ba46c7 |
"entryrdn_rename_subtree: Adding %s failed; "
|
|
|
ba46c7 |
"%s(%d)\n", keybuf, dblayer_strerror(rc), rc);
|
|
|
ba46c7 |
@@ -769,7 +769,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
ba46c7 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &key,
|
|
|
ba46c7 |
&renamedata, RDN_INDEX_CHILD, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
@@ -814,7 +814,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
ba46c7 |
renamedata.data = (void *)newsupelem;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
ba46c7 |
"entryrdn_rename_subtree: Adding "
|
|
|
ba46c7 |
"%s failed; %s(%d)\n",
|
|
|
ba46c7 |
@@ -849,7 +849,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
ba46c7 |
renamedata.data = (void *)newelem;
|
|
|
ba46c7 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
ba46c7 |
"entryrdn_rename_subtree: Adding %s failed; "
|
|
|
ba46c7 |
"%s(%d)\n", keybuf, dblayer_strerror(rc), rc);
|
|
|
ba46c7 |
@@ -902,7 +902,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
ba46c7 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
@@ -1955,12 +1955,11 @@ _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type, DB_TXN *db_txn)
|
|
|
ba46c7 |
rc = cursor->c_put(cursor, key, data, DB_NODUPDATA);
|
|
|
ba46c7 |
if (rc) {
|
|
|
ba46c7 |
if (DB_KEYEXIST == rc) {
|
|
|
ba46c7 |
- /* this is okay */
|
|
|
ba46c7 |
+ /* this is okay, but need to return DB_KEYEXIST to caller */
|
|
|
ba46c7 |
slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
|
|
|
ba46c7 |
"_entryrdn_put_data: The same key (%s) and the "
|
|
|
ba46c7 |
"data exists in index\n",
|
|
|
ba46c7 |
(char *)key->data);
|
|
|
ba46c7 |
- rc = 0;
|
|
|
ba46c7 |
break;
|
|
|
ba46c7 |
} else {
|
|
|
ba46c7 |
char *keyword = NULL;
|
|
|
ba46c7 |
@@ -2109,7 +2108,7 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
ba46c7 |
/* adding RDN to the child key */
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_CHILD, db_txn);
|
|
|
ba46c7 |
keybuf = key->data;
|
|
|
ba46c7 |
- if (rc) { /* failed */
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
|
|
|
ba46c7 |
@@ -2125,7 +2124,7 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
ba46c7 |
key->flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_SELF, db_txn);
|
|
|
ba46c7 |
- if (rc) { /* failed */
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
|
|
|
ba46c7 |
@@ -2145,6 +2144,9 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
ba46c7 |
adddata.flags = DB_DBT_USERMEM;
|
|
|
ba46c7 |
/* adding RDN to the self key */
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_PARENT, db_txn);
|
|
|
ba46c7 |
+ if (DB_KEYEXIST == rc) { /* failed && ignore already exists */
|
|
|
ba46c7 |
+ rc = 0;
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
/* Succeeded or failed, it's done. */
|
|
|
ba46c7 |
bail:
|
|
|
ba46c7 |
slapi_ch_free_string(&keybuf);
|
|
|
ba46c7 |
@@ -2268,7 +2270,7 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
|
|
|
ba46c7 |
/* Add it back */
|
|
|
ba46c7 |
rc = _entryrdn_put_data(cursor, &realkey, &moddata,
|
|
|
ba46c7 |
RDN_INDEX_CHILD, db_txn);
|
|
|
ba46c7 |
- if (rc) {
|
|
|
ba46c7 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
ba46c7 |
goto bail0;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
if (curr_childnum + 1 == childnum) {
|
|
|
ba46c7 |
@@ -2531,7 +2533,7 @@ _entryrdn_insert_key(backend *be,
|
|
|
ba46c7 |
slapi_ch_free_string(&dn;;
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
ba46c7 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
ba46c7 |
if (NULL == elem) {
|
|
|
ba46c7 |
char *dn = NULL;
|
|
|
ba46c7 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
ba46c7 |
@@ -2551,12 +2553,13 @@ _entryrdn_insert_key(backend *be,
|
|
|
ba46c7 |
rc = _entryrdn_get_elem(cursor, &key, &data, nrdn, &elem);
|
|
|
ba46c7 |
if (rc) {
|
|
|
ba46c7 |
const char *myrdn = slapi_rdn_get_nrdn(srdn);
|
|
|
ba46c7 |
- const char *ep = NULL;
|
|
|
ba46c7 |
+ const char **ep = NULL;
|
|
|
ba46c7 |
int isexception = 0;
|
|
|
ba46c7 |
/* Check the RDN is in the exception list */
|
|
|
ba46c7 |
- for (ep = *rdn_exceptions; ep && *ep; ep++) {
|
|
|
ba46c7 |
- if (!strcmp(ep, myrdn)) {
|
|
|
ba46c7 |
+ for (ep = rdn_exceptions; ep && *ep; ep++) {
|
|
|
ba46c7 |
+ if (!strcmp(*ep, myrdn)) {
|
|
|
ba46c7 |
isexception = 1;
|
|
|
ba46c7 |
+ break;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
|
|
|
ba46c7 |
@@ -2636,7 +2639,7 @@ _entryrdn_insert_key(backend *be,
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
ba46c7 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
ba46c7 |
if (NULL == elem) {
|
|
|
ba46c7 |
char *dn = NULL;
|
|
|
ba46c7 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
ba46c7 |
@@ -2891,7 +2894,7 @@ _entryrdn_delete_key(backend *be,
|
|
|
ba46c7 |
slapi_ch_free_string(&dn;;
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
ba46c7 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
ba46c7 |
if (NULL == elem) {
|
|
|
ba46c7 |
char *dn = NULL;
|
|
|
ba46c7 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
ba46c7 |
@@ -3134,7 +3137,7 @@ _entryrdn_index_read(backend *be,
|
|
|
ba46c7 |
slapi_ch_free_string(&dn;;
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- *elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
ba46c7 |
+ *elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
ba46c7 |
if (NULL == *elem) {
|
|
|
ba46c7 |
char *dn = NULL;
|
|
|
ba46c7 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
ba46c7 |
@@ -3212,7 +3215,7 @@ _entryrdn_index_read(backend *be,
|
|
|
ba46c7 |
goto bail;
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- tmpelem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
ba46c7 |
+ tmpelem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
ba46c7 |
if (NULL == tmpelem) {
|
|
|
ba46c7 |
char *dn = NULL;
|
|
|
ba46c7 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
ba46c7 |
--
|
|
|
ba46c7 |
1.7.1
|
|
|
ba46c7 |
|