mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-28 04:48:58 +00:00
core: request roster (#7121)
This commit is contained in:
@@ -39,6 +39,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20260531_member_removed_at
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260601_relay_sent_web_domain
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260602_group_roster
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260603_simplex_name
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260629_roster_catchup
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -77,7 +78,8 @@ schemaMigrations =
|
||||
("20260531_member_removed_at", m20260531_member_removed_at, Just down_m20260531_member_removed_at),
|
||||
("20260601_relay_sent_web_domain", m20260601_relay_sent_web_domain, Just down_m20260601_relay_sent_web_domain),
|
||||
("20260602_group_roster", m20260602_group_roster, Just down_m20260602_group_roster),
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name)
|
||||
("20260603_simplex_name", m20260603_simplex_name, Just down_m20260603_simplex_name),
|
||||
("20260629_roster_catchup", m20260629_roster_catchup, Just down_m20260629_roster_catchup)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260629_roster_catchup where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
-- Roster catch-up bookkeeping. Three monotonic per-group roster versions with distinct roles - normally equal,
|
||||
-- diverging across gaps and failed transfers (applied_complete <= stored <= roster_version):
|
||||
-- roster_version (added in M20260602) - the GATE: highest version seen. Advanced by every accepted owner delta
|
||||
-- and by a roster apply. Revert protection: a completing roster older than this is rejected, since its
|
||||
-- snapshot would undo a newer applied delta.
|
||||
-- stored_roster_version - the blob HELD: the version of the roster blob actually stored (written with the blob).
|
||||
-- What a relay can re-serve; a failed blob receive leaves it behind the gate (which the delta still advances)
|
||||
-- until a later roster completes. Relay-side; on a member it is set but the blob is unused.
|
||||
-- applied_complete_roster_version - the COMPLETE frontier: highest version up to which the picture is contiguous.
|
||||
-- Advances by 1 on a contiguous delta and to the roster's version on apply, but stays put on a gapped delta.
|
||||
-- The subscriber's "what I have" for gap detection and the catch-up request: a value below the gate means
|
||||
-- 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
|
||||
down_m20260629_roster_catchup =
|
||||
[r|
|
||||
ALTER TABLE group_members DROP COLUMN roster_served_version;
|
||||
ALTER TABLE groups DROP COLUMN stored_roster_version;
|
||||
ALTER TABLE groups DROP COLUMN applied_complete_roster_version;
|
||||
|]
|
||||
@@ -834,7 +834,8 @@ CREATE TABLE test_chat_schema.group_members (
|
||||
member_relations_vector bytea,
|
||||
relay_link bytea,
|
||||
member_pub_key bytea,
|
||||
removed_at timestamp with time zone
|
||||
removed_at timestamp with time zone,
|
||||
roster_served_version bigint
|
||||
);
|
||||
|
||||
|
||||
@@ -994,7 +995,9 @@ CREATE TABLE test_chat_schema.groups (
|
||||
roster_sending_owner_gm_id bigint,
|
||||
roster_broker_ts timestamp with time zone,
|
||||
roster_blob bytea,
|
||||
group_domain_verified smallint
|
||||
group_domain_verified smallint,
|
||||
stored_roster_version bigint,
|
||||
applied_complete_roster_version bigint
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user