From 5a7add3e5f7be1e2e81d8225472a7a4cb8f7bf3e Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 30 Jun 2026 20:54:31 +0400 Subject: [PATCH] wip --- .../Store/Postgres/Migrations/M20260629_roster_catchup.hs | 4 ++++ .../Chat/Store/SQLite/Migrations/M20260629_roster_catchup.hs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Simplex/Chat/Store/Postgres/Migrations/M20260629_roster_catchup.hs b/src/Simplex/Chat/Store/Postgres/Migrations/M20260629_roster_catchup.hs index 18bd2e5fd3..f5b94e7d0b 100644 --- a/src/Simplex/Chat/Store/Postgres/Migrations/M20260629_roster_catchup.hs +++ b/src/Simplex/Chat/Store/Postgres/Migrations/M20260629_roster_catchup.hs @@ -20,12 +20,16 @@ import Text.RawString.QQ (r) -- missed versions, so each following delta re-asks the forwarding relay until a roster fills the frontier. -- Also adds group_members.roster_served_version - the newest version a relay re-served a given member, bounding -- reflected amplification (a member can't re-trigger a full serve at a version it was already served). +-- Backfill an existing roster's stored and complete versions from roster_version: pre-upgrade the picture is +-- contiguous up to roster_version (no gap detection existed), so a fresh NULL frontier would read every group's +-- next delta as a gap and make every subscriber request a re-serve at once. m20260629_roster_catchup :: Text m20260629_roster_catchup = [r| ALTER TABLE group_members ADD COLUMN roster_served_version BIGINT; ALTER TABLE groups ADD COLUMN stored_roster_version BIGINT; ALTER TABLE groups ADD COLUMN applied_complete_roster_version BIGINT; +UPDATE groups SET stored_roster_version = roster_version, applied_complete_roster_version = roster_version WHERE roster_version IS NOT NULL; |] down_m20260629_roster_catchup :: Text diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/M20260629_roster_catchup.hs b/src/Simplex/Chat/Store/SQLite/Migrations/M20260629_roster_catchup.hs index 35182cf746..1dacc665ea 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/M20260629_roster_catchup.hs +++ b/src/Simplex/Chat/Store/SQLite/Migrations/M20260629_roster_catchup.hs @@ -19,12 +19,16 @@ import Database.SQLite.Simple.QQ (sql) -- missed versions, so each following delta re-asks the forwarding relay until a roster fills the frontier. -- Also adds group_members.roster_served_version - the newest version a relay re-served a given member, bounding -- reflected amplification (a member can't re-trigger a full serve at a version it was already served). +-- Backfill an existing roster's stored and complete versions from roster_version: pre-upgrade the picture is +-- contiguous up to roster_version (no gap detection existed), so a fresh NULL frontier would read every group's +-- next delta as a gap and make every subscriber request a re-serve at once. m20260629_roster_catchup :: Query m20260629_roster_catchup = [sql| ALTER TABLE group_members ADD COLUMN roster_served_version INTEGER; ALTER TABLE groups ADD COLUMN stored_roster_version INTEGER; ALTER TABLE groups ADD COLUMN applied_complete_roster_version INTEGER; +UPDATE groups SET stored_roster_version = roster_version, applied_complete_roster_version = roster_version WHERE roster_version IS NOT NULL; |] down_m20260629_roster_catchup :: Query