OpenSUSE Leap 15.6 introduces zypper search offset and limit: what are the implications for pagination consistency?
0 reputation · 02 Jan 2025, 20:21 UTC
0 reputation · 02 Jan 2025, 20:21 UTC
OpenSUSE Leap 15.6 added --offset and --limit flags to zypper search, allowing administrators to retrieve a specific slice of package entries from a repository. This feature is intended to reduce memory usage and improve CLI responsiveness when dealing with thousands of packages.
The implementation relies on a simple numeric offset, which can lead to duplicate or missing entries if the underlying repository changes between paginated requests. Additionally, large offset values still require the engine to traverse all preceding entries, potentially degrading performance. The documentation notes that the offset/limit feature is experimental and may be replaced by a cursor‑based API in future releases.
zypper search?29275 reputation · 02 Jan 2025, 21:14 UTC
In Leap 15.6 the zypper search command can now be sliced with --offset and --limit. The implementation is a simple numeric offset that walks the internal package list sequentially, then returns the next limit entries. Because the traversal is linear and no snapshot or cursor is kept, the page contents can change if the repository is modified between calls. Thus:
The offset/limit logic is implemented in zypper.cpp by iterating over a std::vector of all available packages. The offset is simply a counter; the engine does not remember any previous state. Consequently:
zypper search call, the engine cannot detect concurrent changes.--offset and --limit as experimental flags.zypper search --offset 0 --limit 10 followed by zypper search --offset 10 --limit 10 on a static repository yields two non‑overlapping lists.For production use where pagination consistency is critical, freeze the repository state before paging. The simplest way is to clone the repository to a local mirror and run all zypper search commands against that mirror. If you must page through a live repository, accept that duplicates or gaps may occur and handle them in downstream logic (e.g., de‑duplicate by package name).
Do you know whether the repositories you query are subject to frequent updates (e.g., during a nightly build cycle) or are static snapshots? This affects whether the above recommendation to use a local mirror is necessary.
| Label |
|---|
| Offset/Limit Pagination |
| Linear Scan Cost |
| Dynamic Repository |
| Consistency Issues |
zypper search --offset 0 --limit 10
zypper search --offset 10 --limit 10
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.