pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Google Cloud Bucket support

Open ai opened this issue 9 months ago • 2 comments

When I mount Google Cloud Storage Bucket and use it as pglite path, it created pgdata/ folder and then app crashes.

Does pglite has some issue with Google Cloud FUSE limitations or just don’t support this mode?

I understand that it is very slow way to use database. But I think this mode is important for prototypes when you want some permanent storage but don’t want to pay for separated machine on Google Cloud for database.

Here is my code:

ai avatar Mar 11 '25 00:03 ai

Did you happen to get the error logs from when it crashed? If you could post them (use debug: 1) that would help a lot in working out why it crashes.

I'm not aware of anyone who has tried with a FUSE based file system.

samwillis avatar Mar 13 '25 12:03 samwillis

Thanks! I didn’t know about debug: 1. But logs are strange, I think I need your help.

The JS code:

console.log('DB Location:', config.db)
pglite = new PGlite(config.db, { debug: 1 })

I mount Google Cloud bucket to /var/mnt/db:

--add-volume name=db,type=cloud-storage,bucket=slowreader-staging-db
--add-volume-mount volume=db,mount-path=/var/mnt/db

But I got logs where pglite try to look at /tmp

DB Location: file:///var/mnt/db/pgdata
pglite: no db
# WARNING: program "postgres" is needed by initdb but was not found in the same directory as "/tmp/pglite/bin/initdb"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
# 3442
The database cluster will be initialized with this locale configuration:
  provider:    libc
  LC_COLLATE:  C
  LC_CTYPE:    C.UTF-8
  LC_MESSAGES: C
  LC_MONETARY: C
  LC_NUMERIC:  C
  LC_TIME:     C
# 2651
# 2705
# 2706
# 3444
The default text search configuration will be set to "english".
# 3446
Data page checksums are disabled.
# 3458
popen failure: Function not implemented
error: could not change permissions of directory "/tmp/pglite/base": Operation not permitted

ai avatar Mar 13 '25 18:03 ai

@ai error: could not change permissions of directory "/tmp/pglite/base": Operation not permitted

Can you please check the permissions on /var/mnt/db?

tdrz avatar Jul 16 '25 07:07 tdrz

Thanks, seems like it was a reason https://github.com/hplush/slowreader/commit/b9012b101e0d2b3c85ed8bb65c0edbcd18f484ed

I am closing this issue. But why we have /tmp/pglite/base path in the log?

ai avatar Jul 16 '25 22:07 ai

But why we have /tmp/pglite/base path in the log?

@ai we use emscripten's filesystem to store pglite's (postgres') files. the emscripten fs is mouted at / and we use /tmp/pglite/base.

tdrz avatar Jul 17 '25 06:07 tdrz

@tdrz hm, the wrong path was the reason why I stopped debugging and open an issue. If it was confused, it may confuse others. Not urgent, but we can do log.replaceAll('/tmp/pglite/base', path) replacement in JS wrapper around WASM.

ai avatar Jul 17 '25 11:07 ai

@ai Unsure what you mean. The path in the log is correct.

There is a mapping of the host path to the wasm environment (in your case /var/mnt/db -> /. That is why you needed to change the permissions on /var/mnt/db.

tdrz avatar Jul 17 '25 13:07 tdrz