Skip to content

feat(sync): evict ghost items via deferred synthetic deletions#90

Draft
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
feat/ghost-item-eviction
Draft

feat(sync): evict ghost items via deferred synthetic deletions#90
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
feat/ghost-item-eviction

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Self-heal "ghost" items: mail a client may still hold although it was
    deleted server-side long ago and the client never applied the Remove.
  • Detection at Fetch time, eviction deferred through the regular change
    pipeline (never in the Fetch response itself).

Motivation

When a mail is deleted via IMAP/webmail, the server sends a Remove once.
If the client fails to apply it (observed with iOS Mail), the client
retries SYNC_FETCH for the vanished item indefinitely; the diff engine
can never delete an untracked uid again, so the loop never ends.
Answering with Status 8 alone does not recover iOS.

An earlier variant that emitted the Remove in the same Sync response as
the Fetch reply reproducibly crashed iOS maild (SIGABRT parsing
assertion, crash loop with 20-minute throttling). Hence the deferred
design: record the ghost uid, deliver the Remove in a normal GetChanges
response — the shape every client already handles.

Changes

  • Exporter_Sync::fetchIds() records NotFound failures;
    getFailedFetchIds() exposes them.
  • Request_Sync::_getGhostFetchIds() filters failures to uids untracked
    in the folder state and records them via State_Base::addGhostUids().
  • Folder_Imap persists ghost uids (new optional g key, BC in both
    directions) with add/list/remove API.
  • State_Base::getChanges() injects synthetic CHANGE_TYPE_DELETE
    entries for recorded ghosts (also in PING mode, so the device is woken
    to pick up the eviction); the uid is cleared once the deletion is
    exported. Uids tracked again in state are dropped without eviction.

Expected exception types

No new catch blocks; existing Horde_Exception_NotFound handling in
fetchIds() is reused.

Test plan

  • 16 new unit tests (exporter failure tracking, folder ghost API and
    serialization, ghost detection, state injection/clearing)
  • Full package suite: no new failures
  • Verified live: iOS device recovered, ghost item evicted, fetch
    loop ended

A mail deleted through another vector (IMAP client, webmail) may leave
a "ghost" item on a client that fails to apply the Remove command sent
at deletion time; iOS Mail then retries the SYNC_FETCH for the
vanished item forever. Detect this case (Fetch fails with NotFound and
the uid is untracked in the folder state), record the uid in the
folder state, and export a synthetic deletion through the regular
change pipeline on a later GetChanges Sync.

The eviction Remove is deliberately NOT emitted in the same response
as the Fetch reply: iOS maild crashes (SIGABRT assertion loop) when a
Sync response combines a Fetch reply with a Remove command for the
same item.
@github-actions

Copy link
Copy Markdown

🔍 CI Results

Overall: ❌ 12/12 lanes failed

TL;DR: ❌ Quality issues: PHPStan: 242 unique errors in 11 lanes; PHP-CS-Fixer: 25 files.

Summary by PHP Version

PHP dev stable
8.0
8.1
8.2
8.3
8.4
8.5

Quality Metrics

  • PHPUnit: did not run (11 lanes exited non-zero with no test output) ❌
  • PHPStan (advisory): 242 unique errors in 11 lanes ⚠️
  • PHP-CS-Fixer: 25 unique files with issues (of 206 checked) ⚠️
❌ Failed Lanes

php8.0-dev

  • PHPUnit: 0 failures, 0 errors

php8.0-stable

  • PHPUnit: ❌ Setup failed (Composer install failed in /tmp/horde-ci/lanes/php8.0-stable/ActiveSync: Your requirements could not be resolved to an installable set of packages.)
  • PHPStan: ❌ Setup failed (Composer install failed in /tmp/horde-ci/lanes/php8.0-stable/ActiveSync: Your requirements could not be resolved to an installable set of packages.)

php8.1-dev

  • PHPUnit: 0 failures, 0 errors

php8.1-stable

  • PHPUnit: 0 failures, 0 errors

php8.2-dev

  • PHPUnit: 0 failures, 0 errors

php8.2-stable

  • PHPUnit: 0 failures, 0 errors

php8.3-dev

  • PHPUnit: 0 failures, 0 errors

php8.3-stable

  • PHPUnit: 0 failures, 0 errors

php8.4-dev

  • PHPUnit: 0 failures, 0 errors
  • PHP-CS-Fixer: 25 files with issues

php8.4-stable

  • PHPUnit: 0 failures, 0 errors

php8.5-dev

  • PHPUnit: 0 failures, 0 errors

php8.5-stable

  • PHPUnit: 0 failures, 0 errors

CI powered by horde-componentsView full results

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