buzz icon indicating copy to clipboard operation
buzz copied to clipboard

A deleted DM blocks reopening a DM for the same participants

Open flowq-C opened this issue 1 week ago • 0 comments

Summary

A DM that was deleted through the API can never be reopened for the same participants. open_dm fails and the pair stays blocked until someone edits the database by hand.

Reproduction

  1. open_dm for participants A and B (creates a DM).
  2. Delete that DM (soft_delete_channel, i.e. DELETE_GROUP kind 9008 on the DM).
  3. open_dm again for A and B.

Step 3 fails with a DM with these members already exists, although no live DM exists for the pair.

Cause

On main (a79cbb4664c175a4b69026aec610ea549bdfcb2c):

  • crates/buzz-db/src/store/channel.rs:1978: soft_delete_on only sets deleted_at. participant_hash stays on the row.
  • crates/buzz-db/src/store/dm.rs:203-205: find_dm_in matches participant_hash = $2 AND deleted_at IS NULL, so the deleted DM is not found.
  • crates/buzz-db/src/store/dm.rs:385-396: create_dm therefore inserts a new row with the same hash and loses on the unique violation (23505), then looks again, finds nothing live, and reports the conflict.
  • migrations/0001_initial_schema.sql:104-105 (and schema/tables/public/channels.sql:52-53): idx_channels_dm_hash is UNIQUE (community_id, participant_hash) WHERE participant_hash IS NOT NULL. It still covers the deleted row.

Proposal

Make the index partial over live channels too: WHERE participant_hash IS NOT NULL AND deleted_at IS NULL. No data changes, no new objects, and the new index is weaker than the old one, so an older relay keeps working against the migrated database. A migration, the schema file and a Postgres test follow as a PR.

An alternative would be to clear participant_hash in soft_delete_on. That leaves already-deleted rows blocking their pairs and would need a data backfill, so the index change looks simpler.

Note

We have run this index on a self-hosted relay since 2026-10-11: reopening a deleted DM creates a new one (created: true).

flowq-C avatar Nov 20 '26 13:11 flowq-C