postgres-new icon indicating copy to clipboard operation
postgres-new copied to clipboard

Improve resilience of Live Share to psql -f

Open thenonameguy opened this issue 1 year ago • 5 comments
trafficstars

Bug report

While building a demo using the Live Share feature of database.build, I've seen many intermittent failures of the connection. Usually fixed by stopping the Live Share, reloading the tab and restarting the Live Share.

Describe the bug

While running many statements (via psql -f) against a Live Share'd non-trivial DB the server/proxy regularly loses sync, while seemingly hallucinating gigabyte-sized messsage sizes (1853122928 bytes or 1667196005 bytes as examples).

psql:schemamap_init.sql:462: lost synchronization with server: got message type "e", length 1667196005
psql:schemamap_init.sql:462: error: connection to server was lost

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Open database.build
  2. Run prompt: Create a well-modeled ERP schema, with multi-tenancy, constraints on most columns (especially tenant_id) and mock data.
  3. Enable Live Share, copy URI
  4. Download schemamap_init.txt (sql script)
  5. Run: psql -f ./schemamap_init.txt "$URI"
  6. Expectation: it should succeed, although there are sometimes failures here as well
  7. Try rerunning step 5 a few times, eventually you will a get a "lost synchronization".

Expected behavior

The client does not get out of sync.

System information

  • OS:
    • MacOS: psql (PostgreSQL) 15.8
    • Linux: psql (PostgreSQL) 15.8
  • Browser: Firefox 131.0.3 (aarch64)
  • Version of supabase-js: N/A
  • Version of Node.js: N/A

Additional context

I'm aware the client is not major 16 version, but for these simple statement executions, it should not matter.

Another invocation failed later:

psql:schemamap_init.txt:1361: lost synchronization with server: got message type "m", length 1701737504
psql:schemamap_init.txt:1361: error: connection to server was lost

I haven't been able to reproduce the bug on Google Chrome 130.0.6723.92 (Official Build) (arm64)

thenonameguy avatar Nov 01 '24 08:11 thenonameguy