sosedoff / pgweb

Cross-platform client for PostgreSQL databases
https://sosedoff.github.io/pgweb
MIT License
8.56k stars 723 forks source link

SQL export not working #566

Closed Davincible closed 2 years ago

Davincible commented 2 years ago

I have pgweb running in Kubernetes locally with a port forward allowing me to access it.

When I try "Export to SQL" on any random table, it opens up a new tab about:blank. All the other export options do work fine, and open up a popup allowing me to select the download destination.

Since the other functions work fine, I would expect the SQL export to also work.

I'm not sure if this bug is specific to my set up, or pgweb in general

sosedoff commented 2 years ago

Im suspecting your container does not have psql installed, is that correct? Pgweb uses psql under the hood to generate sql dumps.

Davincible commented 2 years ago

I'm using the sosedoff/pgweb image. After shelling in it seems to be installed

sosedoff commented 2 years ago

I think you can start the container with --debug option, it'll display an error. I would like to see your logs when you run export anyway, hard to know what went wrong without it.

Davincible commented 2 years ago

Changed my deployment to

          image: sosedoff/pgweb
          command: 
            - /usr/bin/pgweb
          args:
            - --bind=0.0.0.0
            - --listen=8081
            - --debug

Not so useful logs

pgweb-5d5fdf8876-rs5gc pgweb 2022/06/22 12:24:46 Request params: <nil> map[_session_id:[cf0797b0-1774-c78c-bbab-fa6cd1ce342d] table:["public"."Proxies"]]
pgweb-5d5fdf8876-rs5gc pgweb [GIN] 2022/06/22 - 12:24:46 | 400 |   15.402985ms |       127.0.0.1 | GET      "/api/export?table=%22public%22.%22Proxies%22&_session_id=cf0797b0-1774-c78c-bbab-fa6cd1ce342d"

The only debug message I get is about go routines and mem used

Davincible commented 2 years ago

Ah, after manually curl'ing the export command I get the following:

{
   "error":"error: exit status 1. output: pg_dump: error: server version: 14.3 (Ubuntu 14.3-1.pgdg22.04+1); pg_dump version: 13.6\npg_dump: error: aborting because of server version mismatch\n",
   "status":400
}

Perhaps a good idea to show this error in a notification in the web portal.

I can build my own container to fix the PG version mismatch.

Davincible commented 2 years ago

After running the exact Dockerfile locally it does install pg_dump v14, I think at the time you build the container it installed the older version. Rebuilding the sosedoff/pgweb container should fix this I think

Davincible commented 2 years ago

@sosedoff could you please rebuild and push the docker image so it updates the pg_dump version?

sosedoff commented 2 years ago

While i can rebuild the image, i think we should also pin the postgres client libraries to a specific version, like 14.

Davincible commented 2 years ago

You could mention them in the image tags (e.g. like Timescaldb mentions both the timescale version and pg version in their tags). Since they're all backward compatible I think someone rarely would want to use an older version specifically. It would make it much clearer on first sight to see what you're working with

sosedoff commented 2 years ago

I would like to avoid having this kind of "matrix" of builds if possible, however you can open up a new issue on that topic, i can work something out for new releases.

Davincible commented 2 years ago

Fair enough. Perhaps you could release an 0.11.12 image just to upgrade Postgres

sosedoff commented 2 years ago

Good call - i just implemented automation for docker images , so 0.11.12 could be a good candidate to test that out.