You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(pglite-sync): don't filter move-in messages by LSN (#883)
* fix(pglite-sync): don't filter move-in messages by LSN
Move-in messages from Electric's tagged_subqueries feature don't have
an LSN header because they come from direct DB queries, not replication.
Previously these messages were incorrectly skipped as "already seen"
because the missing LSN defaulted to 0.
This checks for the is_move_in header and bypasses LSN filtering for
move-in messages, ensuring rows moving into a shape due to subquery
condition changes are properly synced.
Fixeselectric-sql/electric#3769
* fix(pglite-sync): handle move-in duplicate keys with ON CONFLICT
Move-in data from tagged_subqueries can overlap with initial sync data,
causing duplicate key errors. This adds ON CONFLICT DO UPDATE handling
specifically for move-in inserts.
- Add primaryKey param to applyInsertsToTable
- Use ON CONFLICT DO UPDATE for move-in inserts
- Update changeset description
* Add regression tests for move-in messages
* Fix formatting
---------
Co-authored-by: msfstef <msfstef@gmail.com>
Fix move-in messages from tagged_subqueries not being synced
6
+
7
+
This fixes two issues with move-in messages from Electric's `tagged_subqueries` feature:
8
+
9
+
1.**LSN filtering bypass**: Move-in messages don't include an LSN header because they originate from direct database queries rather than the PostgreSQL replication stream. Previously, these messages were being filtered out as "already seen" because the missing LSN defaulted to 0. This fix checks for the `is_move_in` header and bypasses LSN filtering for these messages.
10
+
11
+
2.**Duplicate key handling**: Move-in data can overlap with data from the initial sync (e.g., when a row "moves in" to match a subquery that it already matched during initial sync). This fix uses `ON CONFLICT DO UPDATE` for move-in inserts to handle these duplicates gracefully, updating the row with the latest data instead of erroring.
0 commit comments