Skip to content

Conversation

@akshaymankar
Copy link
Member

@akshaymankar akshaymankar commented Oct 9, 2025

https://wearezeta.atlassian.net/browse/WPB-20751

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@akshaymankar akshaymankar force-pushed the conversation-postgres-ci branch from c32b073 to 4e1c43c Compare October 13, 2025 09:39
@akshaymankar akshaymankar force-pushed the conversation-migration branch from 905ece0 to ea4a8bd Compare October 13, 2025 09:39
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Oct 13, 2025
@akshaymankar akshaymankar force-pushed the conversation-postgres-ci branch from 4e1c43c to 619999d Compare October 13, 2025 11:40
@akshaymankar akshaymankar force-pushed the conversation-migration branch from ea4a8bd to ce9435e Compare October 13, 2025 11:42
Base automatically changed from conversation-postgres-ci to develop October 13, 2025 13:36
@akshaymankar akshaymankar force-pushed the conversation-migration branch 2 times, most recently from 2b79ef3 to 5090c28 Compare October 15, 2025 08:35
@akshaymankar akshaymankar force-pushed the conversation-migration branch 2 times, most recently from 4ca15c9 to e44c50d Compare October 28, 2025 12:19
… during migration

Exceptions:
1. Getting a paginated list of qualified conv Ids
2. It will not work well if the migration fails to delete conv data from
Cassandra after copying it to postgres

These problems will be solved in following commits
When fetching `maxIds + 1` convs, it can happen that a user has exactly those
many convs left, in this case the `hasMore` field of the page would be false,
but we'd be sending a truncated list of convs.
This is done by making the pagingState encode last conversation Id served. The
store effect has a new action to list only remote conv ids. The
`GetConverastionIds` action has been removed and implemented generally using
`GetLocalConverastionIds` and `GetRemoteConversationIds`.

This makes `MultiTabelPage` type obsolete for conv ids, but its still kept
around so we don't break any APIs.
…nv in postgres

This is consistent with creating new conversations in postgres. This way when
the migration is complete already running galley instances won't create more
data in Cassandra
…ndra are never read

Exception: Listing local conversation ids and listing team conversation ids
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for migrating conversation data from Cassandra to PostgreSQL, enabling channel search and management in team UI. The migration occurs in three phases: preparation (write to both DBs), active migration (background worker moves existing data), and PostgreSQL-only operation.

Key changes:

  • Adds a new MigrationToPostgresql storage location option for phased migration
  • Implements background worker to migrate conversations and remote member data
  • Introduces migration locks to prevent race conditions during concurrent operations

Reviewed Changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
services/galley/src/Galley/Options.hs Adds new MigrationToPostgresql storage option with documentation
services/galley/src/Galley/App.hs Adds polysemy-conc dependency and MigrationError handling
libs/wire-subsystems/src/Wire/ConversationStore/*.hs Implements dual-write interpreter and migration logic
services/background-worker/src/Wire/*.hs Adds migration worker with Prometheus metrics
charts/background-worker/*.yaml Adds Cassandra Galley connection and PostgreSQL config
integration/test/Test/Conversation/Migration.hs Comprehensive migration tests for MLS and Proteus conversations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@akshaymankar akshaymankar requested a review from Copilot October 29, 2025 15:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

CREATE TABLE conversation_migration_pending_deletes (
typ text NOT NULL,
id uuid NOT NULL,
PRIMARY KEY (typ, id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no foreign key constraint here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to track pending deletes in Cassandra, in case the conv gets deleted from Postgres while its pending in cassandra we don't want to also forget to delete it from Cassandra. So I think it necessary to not create a foreign key, because that will either block conv from being deleted in postgres or if we do a cascading delete, make us forget that this conv needs to be deleted in Cassandra and the migration code will revive this conv.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@akshaymankar akshaymankar force-pushed the conversation-migration branch from 13322d3 to ca61c3c Compare October 30, 2025 14:57
Also stop any throttling, OOMKilling
@akshaymankar akshaymankar force-pushed the conversation-migration branch from ca61c3c to 192ce20 Compare October 30, 2025 15:19
@akshaymankar akshaymankar force-pushed the conversation-migration branch from e775514 to e08cf96 Compare November 4, 2025 09:47
@akshaymankar akshaymankar force-pushed the conversation-migration branch from 378682d to 0f3c1a2 Compare November 4, 2025 10:04
@akshaymankar akshaymankar merged commit cc06340 into develop Nov 5, 2025
10 checks passed
@akshaymankar akshaymankar deleted the conversation-migration branch November 5, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants