Deleted mail keeps its blobs while a separate search store is down

On v1.1.1 with a separate search store (PostgreSql here; ElasticSearch and Meilisearch take the same path), the index worker clears a deleted email’s blob link, Metadata and SortKeys in the same batch as the search unindex. That batch is written only after the search store accepts the deletes (services/src/index_queue/index.rs:275 flush, then :295 write). While the search store is down, the partition fails and retries (index_queue/mod.rs:37-38: 30 s doubling to 30 min, no limit), and purgeBlob keeps every blob that still has a link (store/src/write/blob.rs:163-291).

Test, v1.1.1, single node, data store PG 18.7, search store a second PG 18.7 (responseTimeout 120 s). 199 messages were delivered and indexed. All were then destroyed by JMAP, with a 180 s wait before purgeAccounts + purgeBlob:

Search store Blob files freed during the fault Search queue (y) rows Partition (IndexQueueStatus)
healthy (control) 199 of 199 0 (none)
disk frozen (dmsetup suspend) 0 of 199 200 Running, queuedDeletions 199, no error logged
stopped 0 of 199 201 Failed, “Connection refused”, nextRetry 30 s ahead

The mail was gone for the user at once (Email/query 0), and 20 new messages still arrived during each fault. With the disk frozen, the flush simply hung for the whole 231 s outage. responseTimeout didn’t end it, nothing was logged, and the partition showed Running, so nothing in IndexQueueStatus looked wrong. With the store stopped, 4 search-index.partition-retry events were logged at debug level only. The store was down 233 s, and on restore the partition was still Failed with the next retry 3.6 min away. Setting it to Running drained the queue in 15 s, and the next purge freed the 179 deleted blobs (the 20 new ones kept). In the frozen case the queue drained as soon as the disk came back. Data-store writes stayed under 0.04 s throughout, so deletes themselves were not slowed.

I think the ordering is deliberate (the index must not point at metadata that is gone), and nothing is lost. But a search store outage, or one that is retired without changing SearchStore, quietly stops space reclamation, and storage/maintenance.md (“Disk usage does not drop after deleting mail”) does not list this. The partition failure is logged at debug (storage/indexing.md), and a hung store doesn’t fail the partition at all, so at the default level nothing shows it.

Ideas, any one would help:

  1. Clear the data-store side of a deletion (links, Metadata, SortKeys) at once, or after a bounded number of failed flushes, and keep a small tombstone for the search unindex.
  2. Keep deletions from waiting on failed inserts in the same partition.
  3. Put a deadline on the search flush, so a hung store fails the partition instead of showing Running.
  4. Add this to storage/maintenance.md, and log the partition failure at warn after some time.

Topic 2107 (a partition retried forever, fixed in v1.1.0) is related but a different cause.

Tested and written with AI help.