[BUG] Search index deduplication failing — duplicate archive entries on every sync
Bichon version: 1.3.0 (released 2026-05-24) Installation method: Proxmox LXC via community-scripts IMAP server: mx.serverhostgroup.com (third-party hosted) Log level used for diagnosis: debug
Describe the bug
On every sync cycle, the majority of already-archived emails are being written to the Tantivy search index as new entries, resulting in duplicate records appearing in the archive UI. The duplicates accumulate with each sync — an email archived on the first run will gain one additional duplicate entry per subsequent sync.
This affects multiple accounts, all on the same IMAP server, and the majority (but not all) of emails in those accounts.
Critical finding from debug logs
The debug logs clearly show that blob storage deduplication is working correctly — the raw email content is recognised as already stored and skipped:
DEBUG bichon_core::store::blob: Email blob already exists (dedup): 0b4e39f735cd434f425035c545327ee1b807b45df95c3e58d344fa7777619a38
However, immediately after this dedup hit, new Tantivy index segment files are written regardless:
Open Write "061bf13179a44249822473920a86984c.store"
Open Write "061bf13179a44249822473920a86984c.fast"
Open Write "061bf13179a44249822473920a86984c.fieldnorm"
Open Write "061bf13179a44249822473920a86984c.term"
Open Write "061bf13179a44249822473920a86984c.idx"
Open Write "061bf13179a44249822473920a86984c.pos"
This demonstrates a clear disconnect between the two storage layers: the blob store correctly identifies and skips the duplicate, but this does not prevent a new entry from being written to the search index. The result is that the archive UI shows multiple identical entries for the same email, even though only one copy of the raw content exists on disk.
What is not causing this
The debug logs were also checked for UIDVALIDITY changes between sync cycles. There are none — the IMAP server is returning consistent UIDs across connections, so server-side UID instability can be ruled out as a cause.
Expected behaviour
When the blob store identifies an email as already archived (dedup hit), no new Tantivy index entry should be written for that email. The two storage layers should be in agreement: if the blob exists, the index entry already exists and the message should be skipped entirely.
Actual behaviour
Blob dedup fires correctly but a new Tantivy index segment is written for the same email on every subsequent sync, creating a growing number of duplicate entries in the archive UI.
Hypothesis
The async index deduplication process (noted in Bichon documentation as being performed asynchronously to reduce write latency) appears to either:
- Not be running after these index writes, or
- Not be correctly identifying and merging duplicate index entries keyed on Message-ID
Alternatively, the sync pipeline may not be checking for an existing index entry before writing a new one, instead relying solely on the async dedup pass to clean up afterwards — which may not be functioning correctly.
Reproduction
- Set up one or more IMAP accounts in Bichon and allow initial sync to complete
- Wait for or trigger a subsequent sync
- Observe duplicate entries appearing in the archive UI for already-archived emails
- Enable debug logging and observe: blob dedup fires correctly, but new Tantivy index writes follow immediately after
Additional context
Happy to provide the full debug log output or run further diagnostic syncs if that would help narrow down the root cause. Please advise if any additional log entries or test scenarios would be useful.