pglite: BUG: Inconsistent Sync - UNUSABLE

The sync is inconsistent:

  • applies the changes with a delay
  • miss some changes

https://github.com/user-attachments/assets/b9e44a87-2342-4e03-9de7-8740e9f08379

The code is pretty simple, I’ve tried with multiple PGLite options, FS, worker mode. Nothing works. Also the shape sync:

await client.electric.syncShapesToTables({
        shapes: {
          profiles: {
            shape: {
              url: 'http://localhost:4000/v1/shape',
              params: { table: 'profiles' },
            },
            table: 'profiles',
            primaryKey: ['id'],
            shapeKey: 'profiles',
          },
          inspection: {
            shape: {
              url: 'http://localhost:4000/v1/shape',
              params: { table: 'inspection' },
            },
            table: 'inspection',
            primaryKey: ['uuid'],
            shapeKey: 'inspection',
          },
        },
        key: 'syncBase_v1',
});

Docker ElectricSync Docker: 1.12

Package Json "@electric-sql/pglite": "0.3.0" "@electric-sql/pglite-sync": "0.3.2"

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 36 (6 by maintainers)

Most upvoted comments

ETA for this fix?

@balegas I tried but no joy.

Do you guys need more info or are you investigating? We would like to pilot a GOV AI product and we need this working in a few weeks, otherwise we may create our own pull engine for supabase.

@samwillis using the client.electric.syncShapeToTable instead of the client.electric.syncShapesToTables seems to work by the way.

It gives a different error, but seems to not affect the functionality:

Uncaught (in promise) Error: duplicate key value violates unique constraint “inspection_pkey” at BroadcastChannel.a (index.js:209:25)
a
@index.js:209

There is no reason to throw this, I don’t even understand what is trying to do

Ok this could be caused by duplicated subscriptions. I’ll try to move the sync instructions to the worker

Moved to the worker seems to have inconsistency similar to the multi table one.

@samwillis using the client.electric.syncShapeToTable instead of the client.electric.syncShapesToTables seems to work by the way.

It gives a different error, but seems to not affect the functionality:

Uncaught (in promise) Error: duplicate key value violates unique constraint “inspection_pkey” at BroadcastChannel.a (index.js:209:25)
a
@index.js:209

There is no reason to throw this, I don’t even understand what is trying to do

Ok this could be caused by duplicated subscriptions. I’ll try to move the sync instructions to the worker

@samwillis using the client.electric.syncShapeToTable instead of the client.electric.syncShapesToTables seems to work by the way.

It gives a different error, but seems to not affect the functionality:

Uncaught (in promise) Error: duplicate key value violates unique constraint “inspection_pkey” at BroadcastChannel.a (index.js:209:25)
a
@index.js:209

There is no reason to throw this, I don’t even understand what is trying to do