Skip to content

Issue 6141 - freeipa test_topology_TestCASpecificRUVs is failing #6144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

progier389
Copy link
Contributor

@progier389 progier389 commented Apr 9, 2024

On lmdb, vlv search using a value instead of range may fail (set target on first record instead of smallest record whose key is greater of equal to the wanted value).
The reason is that a test is inverted when walking the cursor to find the record position so the loop end after first iteration.
Also fix a coverity scan warning

Issue: #6141

Reviewed by: @tbordaz

@progier389 progier389 linked an issue Apr 9, 2024 that may be closed by this pull request
}
while (rc == 0) {
cmpres = dbmdb_cmp_dbi_record(mdb_cursor_dbi(cursor->cur), &curpos_key, &curpos_data, &rce->key, &rce->data);
if (cmpres >= 0) {
if (cmpres <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I read and reread this code several times and still do not understand it.
I understand that rce starts from the beginning of index and count recno up to curpos_key.
I wound assume that rce.key is lower than cursor_key during the loop and that we stop the loop when it gets higher or equal (the previous code).

The new code is working even if I do not understand it ;).
I would appreciate comments or examples in the code to explain the loop.

Copy link
Contributor Author

@progier389 progier389 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that rce starts from the beginning of index and count recno up to curpos_key.
I wound assume that rce.key is lower than cursor_key during the loop and that we stop the loop when it gets higher or equal

You are right up to that point: the loop should go on while cursor_key > rce.key
and should stop it when cursor_key <= rce.key

(the previous code).

That is wrong: cursor_key <= rce.key is cmpres <= 0 (the new code)
( Looks like I am not the only one that inverts the test ! 😉 )

@progier389 progier389 merged commit 281c027 into 389ds:main Apr 10, 2024
jchapma pushed a commit that referenced this pull request Apr 10, 2024
On lmdb, vlv search using a value instead of range may fail (set target on first record instead of smallest record whose key is greater of equal to the wanted value).
The reason is that a test is inverted when walking the cursor to find the record position so the loop end after first iteration.
Also fix a coverity scan warning

Issue: #6141

Reviewed by: @tbordaz
progier389 added a commit that referenced this pull request May 30, 2024
On lmdb, vlv search using a value instead of range may fail (set target on first record instead of smallest record whose key is greater of equal to the wanted value).
The reason is that a test is inverted when walking the cursor to find the record position so the loop end after first iteration.
Also fix a coverity scan warning

Issue: #6141

Reviewed by: @tbordaz

(cherry picked from commit 281c027)
@progier389 progier389 deleted the i6141 branch May 20, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lmdb - freeipa test_topology_TestCASpecificRUVs is failing
2 participants