Skip to content

Commit

Permalink
Issue 6417 - (2nd) If an entry RDN is identical to the suffix, then E…
Browse files Browse the repository at this point in the history
…ntryrdn gets broken during a reindex (#6460)

Bug description:
	The primary fix has a flaw as it assumes that the
	suffix ID is '1'.
	If the RUV entry is the first entry of the database
	the server loops indefinitely

Fix description:
	Read the suffix ID from the entryrdn index

fixes: #6417

Reviewed by: Pierre Rogier (also reviewed the first fix)
  • Loading branch information
tbordaz committed Jan 6, 2025
1 parent 51b11a7 commit 3a0fa37
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dirsrvtests/tests/suites/replication/regression_m2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,15 @@ def test_online_reinit_may_hang(topo_with_sigkill):
"""
M1 = topo_with_sigkill.ms["supplier1"]
M2 = topo_with_sigkill.ms["supplier2"]

# The RFE 5367 (when enabled) retrieves the DN
# from the dncache. This hides an issue
# with primary fix for 6417.
# We need to disable the RFE to verify that the primary
# fix is properly fixed.
if ds_is_newer('2.3.1'):
M1.config.replace('nsslapd-return-original-entrydn', 'off')

M1.stop()
ldif_file = '%s/supplier1.ldif' % M1.get_ldif_dir()
M1.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX],
Expand Down
19 changes: 18 additions & 1 deletion ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,7 @@ entryrdn_lookup_dn(backend *be,
rdn_elem *elem = NULL;
int maybesuffix = 0;
int db_retry = 0;
ID suffix_id = 1;

slapi_log_err(SLAPI_LOG_TRACE, "entryrdn_lookup_dn",
"--> entryrdn_lookup_dn\n");
Expand Down Expand Up @@ -1123,6 +1124,22 @@ entryrdn_lookup_dn(backend *be,
dblayer_value_free(be, &data);
dblayer_value_init(be, &data);

/* Just in case the suffix ID is not '1' retrieve it from the database */
keybuf = slapi_ch_strdup(slapi_sdn_get_ndn(be->be_suffix));
dblayer_value_set(be, &key, keybuf, strlen(keybuf) + 1);
rc = dblayer_cursor_op(&ctx.cursor, DBI_OP_MOVE_TO_KEY, &key, &data);
if (rc) {
slapi_log_err(SLAPI_LOG_WARNING, "entryrdn_lookup_dn",
"Fails to retrieve the ID of suffix %s - keep the default value '%d'\n",
slapi_sdn_get_ndn(be->be_suffix),
suffix_id);
} else {
elem = (rdn_elem *)data.data;
suffix_id = id_stored_to_internal(elem->rdn_elem_id);
}
dblayer_value_free(be, &data);
dblayer_value_free(be, &key);

do {
/* Setting up a key for the node to get its parent */
keybuf = slapi_ch_smprintf("%c%u", RDN_INDEX_PARENT, workid);
Expand Down Expand Up @@ -1166,7 +1183,7 @@ entryrdn_lookup_dn(backend *be,
}
goto bail;
}
if (workid == 1) {
if (workid == suffix_id) {
/* The loop (workid) iterates from the starting 'id'
* up to the suffix ID (i.e. '1').
* A corner case (#6417) is if an entry, on the path
Expand Down

0 comments on commit 3a0fa37

Please sign in to comment.