[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re[2]: Curious "missing parent" check in mdb_idscopes(), how may this occur?
- To: Howard Chu <hyc@symas.com>, openldap-devel@openldap.org
- Subject: Re[2]: Curious "missing parent" check in mdb_idscopes(), how may this occur?
- From: Konstantin Andreev <andreev@swemel.ru>
- Date: Wed, 30 Oct 2019 20:37:44 +0300
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=swemel.ru; s=17022016; h=Subject:Content-Transfer-Encoding:Content-Type:In-Reply-To: References:To:MIME-Version:From:Date:Message-ID; bh=88pSQcP2Ac+tEECsDtFxZSqEVAaJHG4QvqawcIR6QL4=; b=ieBivhwKPyyNtXvVPM7z6hC++z bdZEQ1urqZZ3aTD47VYv3/Xf2ppovNkuSbXqpvmOgPfVE1wFZW3kjYrc65e+FlWeufXKQzkEa5urR X3+Y2KthZ5+sOhv16DU9OQsN9ARIPtcrzIbFldKzt5pkPIxaW5eiJ8OliPZx9CnM6Uek=;
- In-reply-to: <d3016a9d-2d4b-1ea0-e5ba-97536870df74@symas.com>
- Organization: Swemel JSC
- References: <5DB6D90A.1040102@swemel.ru> <d3016a9d-2d4b-1ea0-e5ba-97536870df74@symas.com>
- User-agent: Mozilla/5.0 (X11; SunOS i86pc; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
Hi, I have carefully traced this part of code and was unable to reproduce what you describe.
If mdb_id2l_search does not find an id in the isc->scopes (lines 782-783, see the excerpt below), the loop just looks id up directly in the dn2id (lines 751-752).
I was also unable to observe that mdb_idscopes could differentiate between paged and non-paged requests, or be affected by the difference. This difference is encapsulated by the caller, mdb_search().
Specifically, if the underlying set of entries changes between page requests, the loop (may) ascend up to "super-root" with zero id. That's exactly what it does for non-paged requests.
And now I am almost sure that the check [if(id == prev)] at line 778 can not succeed, because always compares the parent and child ids coming from the same [child -> parent] record of "dn2id".
Could you, please, take one more look at this part of code? If the check [if(id == prev)] could succeed, could you, please, give a bit more detailed explanation, how may this happen?
Regards, Konstantin.
| 749 while (id) {
| 750 if ( !rc ) {
| 751 key.mv_data = &id;
| 752 rc = mdb_cursor_get( isc->mc, &key, &data, MDB_SET );
...
| 777 /* If we didn't advance, some parent is missing */
| 778 if ( id == prev )
| 779 return MDB_NOTFOUND;
| 780
| 781 x = mdb_id2l_search( isc->scopes, id );
| 782 if ( x <= isc->scopes[0].mid && isc->scopes[x].mid == id ) {
| 783 if ( !isc->scopes[x].mval.mv_data ) {
| 784 /* This node is in scope, add parent chain to scope */
Howard Chu, 28 Oct 2019 20:22 MSK:
If the checks in
http://www.openldap.org/devel/gitweb.cgi?p=openldap.git;a=blob;f=servers/slapd/back-mdb/dn2id.c;h=93fd3e387e968a1928eaa0f82211bcbc3687e777;hb=HEAD#l782
don't find a result, then id doesn't get advanced any further.
This can happen in a pagedResults search when the underlying set of entries changes between page requests.
Konstantin Andreev, 28 Oct 2019 15:03 MSK:
I am contemplating the mdb search mechanics, and puzzled by "missing parent" check in mdb_idscopes():
| /* If we didn't advance, some parent is missing */
| if ( id == prev )
| return MDB_NOTFOUND;
where "id" and "prev" are parent and child ids that come from the same "UP" ( child -> parent ) record of "dn2id" table. Here is a source code approximation for easier reading:
| MDB_val key = { sizeof(ID), & id }, data;
| mdb_cursor_get( "dn2id", key, data, MDB_SET );
| // reading last sizeof(ID) bytes of data.mv_data
| ID prev = *(ID *)(data.mv_data + data.mv_size - sizeof(ID));
IIUC, there is no records in "dn2id" where parent and child ids are the same. There is no by construction, except "super-root", where both ids are zeros, but zero id doesn't follow this execution path.
So, how may [id == prev] occur? Could you, please, explain?
The check came from 5a08b661 and 437f21b commits (ITS#7705,#7800 fix ...), I have read both, but they haven't helped either.