Document LDAP marker pagination as unsupported; fix sizelimit pool poisoning

LDAP has no native keyset pagination, and the server-side paging
cookie cannot survive across stateless HTTP requests in a multi-node
deployment. Marker-based pagination is therefore not supported for
LDAP-backed domains. Callers should not rely on next-link markers.

Additionally, the previous approach of passing sizelimit to
_paged_search_s was broken: when sizelimit caused pagination to stop
mid-page, the server-side LDAP cursor was abandoned without a cancel
request, poisoning the connection pool and causing subsequent requests
to return empty results non-deterministically. This made the limit cap
unreliable in practice.

The fix sets sizelimit=0 always in _ldap_get_all, fetching the full
result set from LDAP. Truncation to the requested limit is handled
reliably in Python by the @driver_hints.truncated decorator.

A regression test pins the documented marker behaviour so future
developers do not mistake the ignored marker for a bug and reintroduce
the broken O(N)-per-page approach.

Closes-Bug: #2161103
Change-Id: I9becfd359e4c21c99da3b8a39df56f17b07341b5
Signed-off-by: Moutaz Chaara <moutaz.chaara@sap.com>
This commit is contained in:
Moutaz Chaara committed 2026-07-31 10:58:41 +02:00
1 parent 30ef2ffa65
commit bbad5c1338
3 files changed
+37 -1

No files matched your search

+7 -1
View File
@@ -1834,7 +1834,13 @@ class BaseLdap:
+ list(self.extra_attr_mapping.keys())
)
)
sizelimit = hints.limit['limit'] if hints and hints.limit else 0
# Always fetch the full result set from LDAP (sizelimit=0 means
# unlimited). Passing a sizelimit to _paged_search_s abandons the
# server-side cursor mid-page, poisoning the connection pool and
# making subsequent requests return empty results non-deterministically.
# Truncation to the requested limit is handled in Python by the
# @driver_hints.truncated decorator after the full set is returned.
sizelimit = 0
with self.get_connection() as conn:
try:
@@ -575,6 +575,22 @@ class LDAPPagedResultsTest(unit.TestCase):
self.assertLessEqual(len(users), list_limit)
def test_marker_ignored_for_ldap_domain(self):
"""LDAP backends do not support marker pagination; markers are ignored.
LDAP has no native keyset pagination and the server-side paging cookie
cannot survive across stateless HTTP requests. Client-side emulation
would require a full directory scan on every page request, which is
unacceptable at scale. The correct behaviour is to ignore the marker
and return results from the beginning of the list, capped by
list_limit. This test pins that behaviour so future developers do not
mistake it for a bug and attempt to "fix" it with an O(N) full fetch.
"""
hints = driver_hints.Hints()
hints.set_marker(uuid.uuid4().hex)
users = PROVIDERS.identity_api.list_users(hints=hints)
self.assertEqual(len(default_fixtures.USERS), len(users))
class CommonLdapTestCase(unit.BaseTestCase):
"""These test cases call functions in keystone.common.ldap."""
@@ -0,0 +1,14 @@
---
fixes:
- |
[`bug 2161103 <https://bugs.launchpad.net/keystone/+bug/2161103>`_]
LDAP-backed domains do not support marker-based (keyset) pagination.
LDAP has no native keyset pagination, and the session cookie required
for native LDAP paging cannot survive across stateless HTTP requests in
a multi-node deployment. Attempting client-side emulation (fetching all
entries to find the marker position) would incur a full directory scan
on every page request, which is unacceptable for large directories.
The ``list_limit`` setting continues to cap the number of entries
returned per request. Callers should not rely on ``next`` link markers
for LDAP-backed domains.