electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.46k stars 204 forks source link

Major upgrade process #289

Closed demize closed 2 months ago

demize commented 2 months ago

I've been working on implementing a database based on pglite for a little bit, and during this process I updated from 0.1.5 to 0.2.5, after which I received this error (reproduced in a temporary directory, since I lost my original output):

wasm://wasm/postgres.wasm-023f75ca:1

RuntimeError: unreachable
    at postgres.wasm.ValidatePgVersion (wasm://wasm/postgres.wasm-023f75ca:wasm-function[4079]:0x22d00e)
    at postgres.wasm.checkDataDir (wasm://wasm/postgres.wasm-023f75ca:wasm-function[4078]:0x22cda3)
    at postgres.wasm.AsyncPostgresSingleUserMain (wasm://wasm/postgres.wasm-023f75ca:wasm-function[8691]:0x370caa)
    at postgres.wasm.pg_initdb (wasm://wasm/postgres.wasm-023f75ca:wasm-function[13269]:0x522243)
    at Module._pg_initdb (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/@electric-sql/pglite/dist/postgres.js:10625:109)
    at Ct.As (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/@electric-sql/pglite/dist/index.js:1:29075)
    at async Ct._e (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/@electric-sql/pglite/dist/index.js:1:30858)
    at async Ct.query (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/@electric-sql/pglite/dist/index.js:1:24527)
    at async PgDialect.migrate (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/drizzle-orm/pg-core/dialect.js:48:5)
    at async migrate (file:///tmp/tmp.SAT8EtxmTE/drizzletest/node_modules/drizzle-orm/pglite/migrator.js:4:3)

This indicates to me that the update to v16 (#112) broke backwards compatibility pretty spectacularly.

It's not an issue for me now (my code hasn't been rolled out yet), but I'd like to continue using pglite for this project, and I'd like to be able to continue updating it; is there any guidance on how to properly upgrade, or any plans to put together such a process?

samwillis commented 2 months ago

Hey @demize

Apologies for the confusion on that one. Postgres maintains binary compatibility within each of its major versions, but not access them. And as you noted we upgraded from a v15dev to v16 release.

Until we reach v1.0, minor changes may break compatibility. I hope we can reach a v1 in the next few months, we may have upgraded to PG v17 by then.

After that any time we upgrade to a new major PG version it will be a major version change to PGlite.

To aid in migrations between versions we are working on a WASM build of pg_dump and pg_restore, so that you can take a SQL dump of the old database and import into a new database. We will not move to v1 until we have this, and the plan is this would be available before we upgrade to PG v17, but I don't want to make that a firm promise.

I hope thats enough assurance there is a plan in place.