Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appserver Postgres Client mismatch #2

Open
dpacassi opened this issue Nov 5, 2021 · 7 comments
Open

Appserver Postgres Client mismatch #2

dpacassi opened this issue Nov 5, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@dpacassi
Copy link

dpacassi commented Nov 5, 2021

When creating a Drupal project with Lando and the following yml file:

name: testproject
recipe: drupal9
config:
  webroot: web
  php: '7.4'
  composer_version: '1.10.22'
  xdebug: false
  database: postgres:13

The DB version is 13 while the client bin versions (psql and pg_dump on appserver) are still on version 10.
If I define another Postgres version in the config, I'd expect that the recipe automatically uses the right version also for the client commands (psql, pg_dump).

I guess this is related to lando/lando#1680. I found a workaround also there.
I added following lines to get the client bins with the right version:

    build_as_root:
      - "apt -y update && apt-get install -y gnupg2 && echo 'deb https://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' >> /etc/apt/sources.list.d/pgdg.list && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && apt -y update && apt-get install -y postgresql-client-13"
@rtfm-47 rtfm-47 transferred this issue from lando/lando Jan 5, 2022
@labboy0276 labboy0276 added bug Something isn't working and removed Needs Triage labels Jan 5, 2022
@Daisuke-sama
Copy link

Daisuke-sama commented Mar 22, 2022

hey!
Same for me, while I am looking for the twelve version.
Also I cannot override the credentials

@labboy0276
Copy link
Contributor

@dpacassi @Daisuke-sama can you please provide steps to replicate. Using the following lando file:

name: d9-postgres
recipe: drupal9
config:
  webroot: .
  php: '7.4'
  xdebug: false
  database: postgres:13

The commands show the right version:

john@tandem:~/lando/1-test-sites/d9-postgres$ lando psql --version
psql (PostgreSQL) 13.5
john@tandem:~/lando/1-test-sites/d9-postgres$ lando psql
psql (13.5)

@Daisuke-sama
Copy link

sure, my steps:

name: web
recipe: lemp
config:
  php: 7.4
  database: postgres:12
//or
services:
  database:
    type: postgres:12
    portforward: 54321

and I get pg_restore --version or sql --version is 10 unless I force the installation of 12 using the run section of the configuration. Because my dump file doesn't load to the database and writes incompatible version.

@Daisuke-sama
Copy link

image

@labboy0276
Copy link
Contributor

strange @Daisuke-sama on this lando file:

name: d9-postgres
recipe: drupal9
config:
  webroot: .
  php: '7.4'
  xdebug: false
  database: postgres:13

I get the following:

john@tandem:~/lando/1-test-sites/d9-postgres$ lando ssh -s database
www-data@5a3068247653:/app$ psql --version
psql (PostgreSQL) 13.5
www-data@5a3068247653:/app$ pg_restore --version
pg_restore (PostgreSQL) 13.5

And on yours:

name: lando-rando
recipe: lemp
config:
  php: 7.4
  database: postgres:12
john@tandem:~/lando/1-test-sites/rando-tests$ lando ssh -s database
www-data@bed14b152d0c:/app$ pg_restore --version
pg_restore (PostgreSQL) 12.9
www-data@bed14b152d0c:/app$ psql --version
psql (PostgreSQL) 12.9

What version of Lando are you on? Have you tried purging your system and starting over? https://docs.lando.dev/help/purging-containers.html

@long-blade
Copy link

Same problem

After purging my system and starting over.

image

@xurizaemon
Copy link

xurizaemon commented Jul 7, 2023

I think the issue description captures this, but our team ran into this and the cause wasn't obvious so I'll add a comment. Here's a minimal repro, showing that with a simple configuration it's possible to see mismatched client versions:

.lando.yml:

name: lando-test
recipe: drupal7
config:
  database: postgres:12

steps to reproduce:

$ lando ssh -s database -c 'pg_restore --version'
pg_restore (PostgreSQL) 12.9

$ lando ssh -s appserver -c 'pg_restore --version'
pg_restore (PostgreSQL) 10.23 (Debian 10.23-1.pgdg110+1)
$ lando ssh -c 'pg_restore --version'
pg_restore (PostgreSQL) 10.23 (Debian 10.23-1.pgdg110+1)

(the last two commands are the same, specifying then omitting the host)

In a Drupal recipe, drush sql:* will be wrapping the appserver versions of the commands, while Lando's sql-import command will use the database host's client tools and versions (unless the user specifies -h).

If the appserver needs matching versions (eg to use drush sql:* commands with PostgreSQL), then a workaround is to add a build step for your appserver to install a matching set of PostgreSQL client commands, as noted by @dpacassi in the issue description.


Working on both postgres and non-postgres projects, I'd probably rather Lando didn't add such a build step by default, unless it applied only to Lando configurations where postgres was used, as I wouldn't want to have to wait for extra steps on a rebuild if the project at hand won't use those tools at all.

NB: @Daisuke-sama #2 (comment) did not behave as expected because the test was done with lando ssh database (which drops the user into an appserver shell), not lando ssh -s database (database shell).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants