Mango Query Pagination with Bookmarks: Handling Index Rebuilds
0 reputation · 10 Dec 2022, 13:59 UTC
Mango Pagination and Bookmarking
When using a Mango selector to retrieve a large collection, the limit and bookmark fields allow the client to iterate through results without using skip. The bookmark is a cursor that references a specific point in the index, enabling efficient forward paging.
Uncertain Behavior on Index Rebuild
In a dynamic database, indexes may be rebuilt automatically or manually. It is unclear whether a bookmark that was issued before an index rebuild remains valid afterward, and if not, how the client should detect and recover from that situation.
Concurrent Document Activity
While pagination is in progress, new documents may be inserted or existing ones deleted. The interaction between these changes and the bookmark’s position may affect the continuity of results, especially when the index is rebuilt in the middle of a paging session.
Open Questions
- Does a bookmark issued against a specific index version survive an automatic or manual rebuild of that index?
- If the bookmark becomes invalid, what response does the server return, and how can a client detect the need to restart pagination?
- Are there recommended patterns for combining bookmarks with
skiporstartkeyto mitigate issues caused by concurrent index changes?