Skip to content

Use INSERT OR IGNORE for excluded_statuses markers#2189

Open
mjhfunctionalashtanga wants to merge 1 commit into
jocmp:mainfrom
mjhfunctionalashtanga:fix/excluded-statuses-insert-or-ignore
Open

Use INSERT OR IGNORE for excluded_statuses markers#2189
mjhfunctionalashtanga wants to merge 1 commit into
jocmp:mainfrom
mjhfunctionalashtanga:fix/excluded-statuses-insert-or-ignore

Conversation

@mjhfunctionalashtanga

Copy link
Copy Markdown

Problem

During refreshUnreadEntriesmarkAllUnread, syncing fails with:

android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed:
excluded_statuses.article_id, excluded_statuses.type (code 1555)
    at com.jocmp.capy.db.ArticlesQueries.upsertUnread

upsertUnread / upsertStarred insert a marker row into excluded_statuses(article_id, type) with no conflict clause (the sibling article_statuses insert correctly uses ON CONFLICT). markAllUnread runs all the marker inserts and the updateStaleUnreads() cleanup — which deletes those markers — in a single transaction. So if any marker already exists (a duplicate ID in the batch, or a marker stranded by an earlier interrupted sync), the insert throws, the whole transaction rolls back, the cleanup never runs, and the leftover markers guarantee the same failure on every subsequent sync. Unread refresh never completes and the client churns.

Fix

Make the marker insert idempotent with INSERT OR IGNORE. Duplicates/leftovers are skipped, the transaction completes, and updateStaleUnreads / updateStaleStars clean up the markers as intended — self-healing.

Verified on a Boox device (Android 11): the recurring db_error disappears and unread refresh completes cleanly.

🤖 Generated with Claude Code

https://claude.ai/code/session_015yVKgdxd3ZSrFeY5eWpFuA

upsertUnread/upsertStarred insert into excluded_statuses(article_id, type) with no conflict clause. markAllUnread runs the marker inserts and the updateStaleUnreads cleanup in one transaction, so a duplicate or stranded marker makes the insert throw, rolls back the transaction, skips the cleanup, and strands the markers -- failing identically on every subsequent sync, so unread refresh never completes. Use INSERT OR IGNORE so duplicate/leftover markers are skipped and the cleanup self-heals.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015yVKgdxd3ZSrFeY5eWpFuA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant