Chunk sync-status IDs to stay under SQLite's variable limit#2188
Open
mjhfunctionalashtanga wants to merge 1 commit into
Open
Chunk sync-status IDs to stay under SQLite's variable limit#2188mjhfunctionalashtanga wants to merge 1 commit into
mjhfunctionalashtanga wants to merge 1 commit into
Conversation
Account.dispatch calls SyncStatusRecords.deleteSelected/resetSelected with the entire queued ID list in one IN(...) clause. SQLite caps bound variables at 999 on the Android-bundled engine (< 3.32), so on a large backlog the statement fails to compile ("too many SQL variables") and the app hard-crashes on every sync until the queue is cleared. Chunk the IDs into batches of 500 within a transaction, matching the existing chunking in Account.markAllRead and ArticleRecords.dismissNotifications.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015yVKgdxd3ZSrFeY5eWpFuA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On an account with a large backlog of queued read/unread changes, the app crashes on every sync (so it never recovers):
Account.dispatchpushes the queued status changes, then callsSyncStatusRecords.deleteSelected(ids, key)/resetSelected(ids, key), which pass the entire ID list into a singleIN (…)clause. SQLite'sSQLITE_MAX_VARIABLE_NUMBERis 999 on the engine bundled with Android (< 3.32), so once more than ~999 changes are queued the statement won't even compile and the app hard-crashes.Fix
Chunk the ID list into batches of 500 (well under the limit, leaving headroom for the
keybind param) inside a transaction — matching the chunking already used byAccount.markAllReadandArticleRecords.dismissNotifications.Reproduced and verified on a Boox device (Android 11) with a ~2,700-entry Miniflux account: the crash is gone and the backlog drains cleanly.
🤖 Generated with Claude Code
https://claude.ai/code/session_015yVKgdxd3ZSrFeY5eWpFuA