Skip to content

[autobackport: sssd-2-9] Improve the performance when using enumeration#8558

Draft
sssd-bot wants to merge 9 commits intoSSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8395-to-sssd-2-9
Draft

[autobackport: sssd-2-9] Improve the performance when using enumeration#8558
sssd-bot wants to merge 9 commits intoSSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8395-to-sssd-2-9

Conversation

@sssd-bot
Copy link
Copy Markdown
Contributor

This is an automatic backport of PR#8395 Improve the performance when using enumeration to branch sssd-2-9, created by @aplopez.

Caution

@aplopez The patches did not apply cleanly. It is necessary to resolve conflicts before merging this pull request. Commits that introduced conflict are marked with CONFLICT!.

You can push changes to this pull request

git remote add sssd-bot git@github.com:sssd-bot/sssd.git
git fetch sssd-bot refs/heads/SSSD-sssd-backport-pr8395-to-sssd-2-9
git checkout SSSD-sssd-backport-pr8395-to-sssd-2-9
git push sssd-bot SSSD-sssd-backport-pr8395-to-sssd-2-9 --force

Original commits
b89f9b6 - SYSDB: Remove unused function
5b5d1ff - NSS: Reduce a possibly extremely long log message
e91c10a - NSS: Fix wrong condition invalidating an optimization
70e78f1 - TESTS: Improve test_sysdb_enumpwent_filter
5284ea6 - NSS: Some optimizations.
670db53 - NSS: Be coherent when using a lastUpdate filter
55e3a30 - NSS: Fix the logged function name
11a15c2 - NSS: Fix sysdb_enumpwent_filter()
0a739f8 - NSS: Better handle ERR_NO_TS in sysdb_enumpwent_filter()

Backported commits

  • 7418338 - SYSDB: Remove unused function
  • d251246 - NSS: Reduce a possibly extremely long log message
  • b5e66da - NSS: Fix wrong condition invalidating an optimization
  • 69a92e5 - TESTS: Improve test_sysdb_enumpwent_filter
  • b3e732f - NSS: Some optimizations.
  • 71bb8da - CONFLICT! NSS: Be coherent when using a lastUpdate filter
  • f070b59 - NSS: Fix the logged function name
  • 0d37930 - NSS: Fix sysdb_enumpwent_filter()
  • c99af80 - NSS: Better handle ERR_NO_TS in sysdb_enumpwent_filter()

Conflicting Files Information (check for deleted and re-added files)

  • CONFLICT! NSS: Be coherent when using a lastUpdate filter
On branch SSSD-sssd-backport-pr8395-to-sssd-2-9
You are currently cherry-picking commit 670db53b1.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/responder/common/cache_req/plugins/cache_req_user_by_filter.c

no changes added to commit (use "git add" and/or "git commit -a")

Original Pull Request Body

This PR includes:

  • Removal of an unused function.
  • Stop logging a possibly extremely long filter.
  • Fixes a wrong condition invalidating an optimization.
  • Adds a test case for an existing test.

Enumeration, specially when there are 15,000+ users, is slow. This fix helps, but it doesn't work miracles.
In my test environment, the enumeration went from 8 minutes to about 1.

It is important to know that, with such an amount of users, many operations time out. It is necessary to increment the timeout in[nss] and for the domain, but also set large values for ldap_enumeration_refresh_timeout and ldap_search_timeout in the domain. I used these values to avoid any timeout (YMMV):

[domain/ldap.test]
ldap_enumeration_refresh_timeout = 30000
ldap_search_timeout = 6000
timeout = 6000
...

[nss]
timeout = 6000
...

aplopez added 9 commits March 27, 2026 18:52
Function sysdb_enumpwent() is not used.
It was replaced by sysdb_enumpwent_filter().

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit b89f9b6)
When there are too many users (17,000+) this message can be too long.
Limit it to the first 50 characters.

Resolves: SSSD#6951
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 5b5d1ff)
We must look into the TS cache only when a name is provided.
Using the TS cache on an unfiltered enumeration is useless.

Resolves: SSSD#6951
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit e91c10a)
Added a case that was not checked before. It is the case
when `attr`, `attr_name` and `addtl_filter` are all `NULL`.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 70e78f1)
Create the filter to retrieve only the requested entries.

Do not create a new filter and search for matches if there is
no results from the previous search. The called functions
handle this case correctly but why wasting time calling them?

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 5284ea6)
Function cache_req_user_by_filter_lookup() will set or not the recent
filter depending on whether data->name.attr is set or not. As mentioned
in the comment, it should be done base on whether the refernced
attribute is name or not.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 670db53)
The message said that sysdb_enumpwent() had failed, but it was
actually sysdb_enumpwent_filter() which failed.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 55e3a30)
The "name" attribute was not being added to the TS cache, even though
that it is part of the DN (ldb doesn't enforce it). Adding this
attribute requires that the DB version is incremented for the TS cache
to be regenerated with the missing attribute.

This made the if-block in sysdb_enumpwent_filter() rather useless.

In addition, once this if-block is executed, the fuction leaves without
further processing.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 11a15c2)
Although ts_res.count is set to 0 when sysdb_search_ts_users()
return ERR_NO_TS, before using it we make an extra check to verify
that the returned code is EOK.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 0a739f8)
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the system database to version 0.26, primarily to include the object name in the timestamp cache and refactor user enumeration logic by removing the sysdb_enumpwent function in favor of sysdb_enumpwent_filter. A critical issue was identified in src/responder/common/cache_req/plugins/cache_req_user_by_filter.c, which contains unresolved merge conflict markers that will prevent the code from compiling.

Comment on lines +93 to +97
<<<<<<< HEAD
if (is_files_provider(domain) || data->name.attr != NULL) {
=======
if (strcmp(attr, SYSDB_NAME) != 0) {
>>>>>>> 670db53b1 (NSS: Be coherent when using a lastUpdate filter)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

This file contains unresolved merge conflict markers. This will cause compilation to fail. Please resolve the conflict before merging. Based on the original pull request, the intended logic appears to be what is suggested below.

    if (strcmp(attr, SYSDB_NAME) != 0) {

@alexey-tikhonov alexey-tikhonov removed their request for review March 27, 2026 19:01
@alexey-tikhonov alexey-tikhonov removed their assignment Mar 27, 2026
@alexey-tikhonov alexey-tikhonov added no-backport This should go to target branch only. Changes requested labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes requested no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants