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

POstgres 15 image does not work with Gitlab backup:restore task - "permission denied for schema public" #168

Open
danobot opened this issue Oct 4, 2023 · 1 comment

Comments

@danobot
Copy link

danobot commented Oct 4, 2023

Due to this change in user permission in postgres 15:
https://stackoverflow.com/questions/74110708/postgres-15-permission-denied-for-schema-public/74111630#comment130849690_74110708

I tried running the db:setup rake task prior to running the backup script.
During backup restore, all SQL statements fail due to permission error.

I am upgrading from 15.11.5 to 16.0.0. Postgres 12 to 15 (using the sameersbn/postgres images).

@danobot danobot changed the title POstgres 15 image does not work with Gitlab backup:restore task = "permission denied for schema public" POstgres 15 image does not work with Gitlab backup:restore task - "permission denied for schema public" Oct 4, 2023
froque added a commit to froque/docker-gitlab that referenced this issue Nov 4, 2023
froque added a commit to froque/docker-gitlab that referenced this issue Nov 4, 2023
froque added a commit to froque/docker-gitlab that referenced this issue Nov 9, 2023
froque added a commit to froque/docker-gitlab that referenced this issue Nov 9, 2023
@elchenberg
Copy link

I might have the same issue.

In my case I created a new database for SonarQube:

      containers:
        - name: postgres
          image: docker.io/sameersbn/postgresql:15@sha256:f5f9f8ad3b873d49a44e21c3f17231da3f92db7f0f73119215b7c771faf53e13
          env:
            - name: DB_NAME
              value: sonar
            - name: DB_PASS
              value: sonar
            - name: DB_USER
              value: sonar

I got permission denied for schema public in SonarQube, too.

As a workaround I used an initContainer (on the SonarQube pod, after the PostgreSQL database is already up and running):

        - name: create-schema
          image: docker.io/sameersbn/postgresql:15@sha256:f5f9f8ad3b873d49a44e21c3f17231da3f92db7f0f73119215b7c771faf53e13
          env:
            - name: PGPASSWORD
              value: sonar
          command:
            - psql
          args:
            - --dbname=sonar
            - --command=CREATE SCHEMA IF NOT EXISTS AUTHORIZATION sonar;
            - --host=postgres
            - --no-password
            - --username=sonar

I am wondering if something like CREATE SCHEMA IF NOT EXISTS AUTHORIZATION sonar; could be added to the create_database function (but my PostgreSQL knowledge is very limited).

Version: docker.io/sameersbn/postgresql:15@sha256:f5f9f8ad3b873d49a44e21c3f17231da3f92db7f0f73119215b7c771faf53e13

PS. I still have to double-check if my workaround actually works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants