Backfill age floor can stop early on out-of-order Date/UID, leaving a history gap #94

Closed
opened 2026-07-02 02:52:44 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-02 02:52:44 +00:00 (Migrated from github.com)

Surfaced during the max-effort code review of PR #46 (default fetch-all history + device-only retention). Below the cut of the reported/fixed findings — filed for tracking.

Problem. MailBackfiller.reachedRetentionFloor (age branch) stops paging once oldestSyncedTimestamp(folder) < cutoff. Backfill pages by UID (≈ arrival order), but the age floor is by the message Date header. A single message with a high UID but an old Date (e.g. moved/imported mail) can drag oldestSyncedTimestamp below the cutoff prematurely, so backfill stops before it has cached all messages that are actually within the age window, leaving a gap.

Location. app/src/main/kotlin/org/libremail/data/sync/MailBackfiller.kt (reachedRetentionFloor).

Impact. Under-fetch: some within-retention history for a folder is never cached. Low probability (needs Date/UID inversion) and no data loss (server copy intact).

Suggested fix. Base the age-floor decision on the batch actually fetched (e.g. stop only once a full page is entirely older than the cutoff), or reconcile against the server's within-window count, rather than the single oldest cached timestamp.

_Surfaced during the max-effort code review of PR #46 (default fetch-all history + device-only retention). Below the cut of the reported/fixed findings — filed for tracking._ **Problem.** `MailBackfiller.reachedRetentionFloor` (age branch) stops paging once `oldestSyncedTimestamp(folder) < cutoff`. Backfill pages by UID (≈ arrival order), but the age floor is by the message Date header. A single message with a high UID but an old Date (e.g. moved/imported mail) can drag `oldestSyncedTimestamp` below the cutoff prematurely, so backfill stops before it has cached all messages that are actually within the age window, leaving a gap. **Location.** `app/src/main/kotlin/org/libremail/data/sync/MailBackfiller.kt` (`reachedRetentionFloor`). **Impact.** Under-fetch: some within-retention history for a folder is never cached. Low probability (needs Date/UID inversion) and no data loss (server copy intact). **Suggested fix.** Base the age-floor decision on the batch actually fetched (e.g. stop only once a full page is entirely older than the cutoff), or reconcile against the server's within-window count, rather than the single oldest cached timestamp.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#94