From ed395544493823a94799e2f937aea7e67e71949e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 9 Apr 2021 11:24:40 +0100 Subject: [PATCH] fedsender: tolerate dupe membership events Previously if the fedsender got a duplicate membership event it would cause the entire process to crash. Now it doesn't. This masks an issue with the roomserver where it can emit duplicate membership events. --- federationsender/storage/postgres/joined_hosts_table.go | 2 +- federationsender/storage/sqlite3/joined_hosts_table.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/federationsender/storage/postgres/joined_hosts_table.go b/federationsender/storage/postgres/joined_hosts_table.go index 0bc9335dd..0c1e91eeb 100644 --- a/federationsender/storage/postgres/joined_hosts_table.go +++ b/federationsender/storage/postgres/joined_hosts_table.go @@ -48,7 +48,7 @@ CREATE INDEX IF NOT EXISTS federatonsender_joined_hosts_room_id_idx const insertJoinedHostsSQL = "" + "INSERT INTO federationsender_joined_hosts (room_id, event_id, server_name)" + - " VALUES ($1, $2, $3)" + " VALUES ($1, $2, $3) ON CONFLICT DO NOTHING" const deleteJoinedHostsSQL = "" + "DELETE FROM federationsender_joined_hosts WHERE event_id = ANY($1)" diff --git a/federationsender/storage/sqlite3/joined_hosts_table.go b/federationsender/storage/sqlite3/joined_hosts_table.go index 1f906808d..3e7673e44 100644 --- a/federationsender/storage/sqlite3/joined_hosts_table.go +++ b/federationsender/storage/sqlite3/joined_hosts_table.go @@ -48,7 +48,7 @@ CREATE INDEX IF NOT EXISTS federatonsender_joined_hosts_room_id_idx const insertJoinedHostsSQL = "" + "INSERT INTO federationsender_joined_hosts (room_id, event_id, server_name)" + - " VALUES ($1, $2, $3)" + " VALUES ($1, $2, $3) ON CONFLICT IGNORE" const deleteJoinedHostsSQL = "" + "DELETE FROM federationsender_joined_hosts WHERE event_id = $1"