electric-sql / electric

Local-first sync layer for web and mobile apps. Build reactive, realtime, local-first apps directly on Postgres.
https://electric-sql.com
Apache License 2.0
5.37k stars 124 forks source link

Electric proxy hangs while creating migrations with Prisma #1401

Closed recurser closed 6 days ago

recurser commented 1 week ago

This is possibly similar to #655, but the LOG_LEVEL seems to have no effect on the behavior. I've tried various versions down to v0.10, rebooted, tried different node versions etc.

Steps to reproduce:

  1. git clone git@github.com:recurser/electric-sql-debugging.git
  2. cd electric-sql-debugging
  3. yarn install

Run the sync service:

  1. make electric-proxy

In another tab:

  1. make prisma-migrate-dev - this very occasionally works, but sometimes hangs
  2. make prisma-migrate-dev - on subsequent runs, it seems to hang on Starting migration engine RPC server.

The prisma debug log gets to SENDING RPC CALL... and seems to hang, migrating nothing.

terminal screencast

linear[bot] commented 1 week ago

VAX-1988 Electric proxy hangs while creating migrations with Prisma

lime517 commented 1 week ago

Just wanted to say - this is a super well put together bug report, IMO. Thank you for setting a great example!

recurser commented 6 days ago

It looks likeElectric SQL hangs while creating the _prisma_migrations table. If you create that table first by hand, everything else works as expected.

CREATE TABLE public._prisma_migrations (
    id character varying(36) NOT NULL,
    checksum character varying(64) NOT NULL,
    finished_at timestamp with time zone,
    migration_name character varying(255) NOT NULL,
    logs text,
    rolled_back_at timestamp with time zone,
    started_at timestamp with time zone DEFAULT now() NOT NULL,
    applied_steps_count integer DEFAULT 0 NOT NULL
);

ALTER TABLE ONLY public._prisma_migrations
    ADD CONSTRAINT _prisma_migrations_pkey PRIMARY KEY (id);

Closing this...

dulichan commented 5 days ago

I am actually getting this issue even when I have created the schema manually

prisma:schemaEngine:stderr {"timestamp":"2024-06-29T08:45:01.826329Z","level":"ERROR","fields":{"message":"Error 
in PostgreSQL connection: Error { kind: Db, cause: Some(DbError { severity: \"FATAL\", parsed_severity: None, code: 
SqlState(E57P01), message: \"terminating connection due to administrator command\", detail: None, hint: None, position: 
None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: 
Some(\"postgres.c\"), line: Some(3206), routine: Some(\"ProcessInterrupts\") }) }"},"target":"quaint::connector::postgres::native"} +15936ms