Skip to content

Batch INSERT Replication Fails for Sizes Divisible by 100 #3726

@blj

Description

@blj

batch_insert_test.exs.txt

Versions

  • Client: Plain HTTP (integration test using Electric.Client)
  • Electric: sync-service (Elixir backend) - current main branch

Bug Description

Batch INSERT statements with row counts exactly divisible by 100 (100, 200, 300, 400, 500, etc.) fail to replicate. The database insert succeeds, but zero messages are received by clients instead of the expected number of change messages.

Affected Batch Sizes

  • Works: 25, 50, 75, 125, 150, 175, 225, 250, 275, 325, 350, 375, 425, 450, 475
  • Fails: 100, 200, 300, 400, 500 (and presumably 600, 700, etc.)

Expected Behavior

When executing a batch INSERT statement with N rows (e.g., INSERT INTO items VALUES (...), (...), ... with 100 rows), the Electric sync service should:

  1. Successfully insert all N rows into the database (this works)
  2. Replicate all N change messages to subscribed clients (this fails for N divisible by 100)
  3. Clients should receive N ChangeMessage events with operation: :insert

Steps to Reproduce

  1. Set up a table and Electric shape subscription
  2. Execute a batch INSERT with exactly 100 rows (or 200, 300, etc.)
  3. Wait for replication
  4. Observe that 0 messages are received instead of 100

Test Case

See attached test file: packages/sync-service/test/integration/batch_insert_test.exs (Please remove the extension .txt as github won't let me attach a .exs file`

  • Test: "receives all rows from batch insert (100 rows)"
  • Expected: 100 messages
  • Actual: 0 messages

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions