Docker-gitlab: postgresql Error tuple concurrently updated

Created on 1 Aug 2016  Â·  9Comments  Â·  Source: sameersbn/docker-gitlab

On my server use sameersbn/gitlab:latest and sameersbn/postgresql:9.4-24

When I try to server gitlab-server I got this message

gitlab_1 | Initializing logdir...
gitlab_1 | Initializing datadir...
gitlab_1 | Updating CA certificates...
postgresql_1 | Initializing certdir...
postgresql_1 | Initializing logdir...
postgresql_1 | Initializing rundir...
postgresql_1 | Setting resolv.conf ACLs...
postgresql_1 | Creating database user: gitlab
postgresql_1 | Creating database: gitlabhq_production...
postgresql_1 | ‣ Loading pg_trgm extension...
postgresql_1 | ‣ Granting access to gitlab user...
postgresql_1 | ERROR: tuple concurrently updated
gitlab_1 | Installing configuration templates...
gitlab_1 | Configuring gitlab...
gitlabdocker_postgresql_1 exited with code 1
postgresql_1 | Initializing datadir...
postgresql_1 | Initializing certdir...
postgresql_1 | Initializing logdir...
postgresql_1 | Initializing rundir...
postgresql_1 | Setting resolv.conf ACLs...
postgresql_1 | Creating database user: gitlab
postgresql_1 | Creating database: gitlabhq_production...
postgresql_1 | ‣ Loading pg_trgm extension...
postgresql_1 | ‣ Granting access to gitlab user...
postgresql_1 | ERROR: tuple concurrently updated
postgresql_1 | Initializing datadir...
postgresql_1 | Initializing certdir...
postgresql_1 | Initializing logdir...
postgresql_1 | Initializing rundir...
postgresql_1 | Setting resolv.conf ACLs...
postgresql_1 | Creating database user: gitlab
postgresql_1 | Creating database: gitlabhq_production...
postgresql_1 | ‣ Loading pg_trgm extension...
postgresql_1 | ‣ Granting access to gitlab user...
postgresql_1 | ERROR: tuple concurrently updated

wontfix

Most helpful comment

I ran into this myself after my server ran into a batch of problems: thermal limit shutdowns and rampant every-minute gitlab backups that led to zero free disk space.

Here's roughly the commands I ran that eventually resolved the issue for me.

cd path/to/gitlab/docker-compose.yml
# Stop all services
docker-compose stop
# Let's get rid of the postgres container. (This may not be necessary. Since it's
# not running, we could probably reuse it for the steps below.)
docker-compose rm postgresql
# Run an interactive shell in a new postgres container
docker-compose run --rm postgresql /bin/bash
# Spin up postgres manually with some verbosity
sudo -u ${PG_USER} -g ${PG_USER} ${PG_BINDIR}/postgres -D ${PG_DATADIR} -d 5
# At this point, postgres just ran with no more "tuple concurrently updated" error.
# Let's shut it down with ctrl+c.

# Let's try running postgres the way it was meant to run, via the entrypoint
/sbin/entrypoint.sh
# Here the "tuple concurrently updated" error appeared.  I waffled a bit between
# the previous step and this one until the error stopped showing up.
# I think I "fixed" it.
# Shut down postgress with ctrl+c.
# Drop out of the interactive container, it'll show itself out the door
exit
# Finally, let's start the postgres service
docker-compose up -d postgresql && docker-compose logs -f
# ...and it's running

Hope you have the same luck I did.

All 9 comments

Hey,
I tested it with your image configuration and I got no problems. Did you try a fresh install or an upgrade. I would recommend you to use a version number of the GitLab image so it's easier to find the problem and you know which version you running.

got the same issue today, after trying to update postgresql container from 9.5-1 to 9.5-3.
Now I can't start postgres at all.

Initializing datadir...
Initializing certdir...
Initializing logdir...
Initializing rundir...
Setting resolv.conf ACLs...
Creating database user: gitlab
Creating database: gitlab_production...
‣ Loading pg_trgm extension...
‣ Granting access to gitlab user...
ERROR:  tuple concurrently updated

same problem here. can anyone remember how to fix it?

I am also experiencing this problem. I should mention that just before the docker host system ran out of free disk space. I made sure that disk space is available and restarted the docker host. Since the restart I am experiencing this problem.

Recently I upgraded from gitlab 9.0.0 to 9.1.4. I am now on postgresql 9.6-2.

I ran into this myself after my server ran into a batch of problems: thermal limit shutdowns and rampant every-minute gitlab backups that led to zero free disk space.

Here's roughly the commands I ran that eventually resolved the issue for me.

cd path/to/gitlab/docker-compose.yml
# Stop all services
docker-compose stop
# Let's get rid of the postgres container. (This may not be necessary. Since it's
# not running, we could probably reuse it for the steps below.)
docker-compose rm postgresql
# Run an interactive shell in a new postgres container
docker-compose run --rm postgresql /bin/bash
# Spin up postgres manually with some verbosity
sudo -u ${PG_USER} -g ${PG_USER} ${PG_BINDIR}/postgres -D ${PG_DATADIR} -d 5
# At this point, postgres just ran with no more "tuple concurrently updated" error.
# Let's shut it down with ctrl+c.

# Let's try running postgres the way it was meant to run, via the entrypoint
/sbin/entrypoint.sh
# Here the "tuple concurrently updated" error appeared.  I waffled a bit between
# the previous step and this one until the error stopped showing up.
# I think I "fixed" it.
# Shut down postgress with ctrl+c.
# Drop out of the interactive container, it'll show itself out the door
exit
# Finally, let's start the postgres service
docker-compose up -d postgresql && docker-compose logs -f
# ...and it's running

Hope you have the same luck I did.

@boxofrox is saving me some sleep this night!

Highlighting something in his answer: It is important to spin up another postgres-Container manually, so you can run sudo -u ${PG_USER} -g ${PG_USER} ${PG_BINDIR}/postgres -D ${PG_DATADIR} -d 5 in it. Then you're able to spin up again your production-container!

Thanks @boxofrox!

@boxofrox thanks for posting this, it is already looking promising.
But can you please explain what these mean

-u ${PG_USER}                  # I am guessing this is a Users for the DB in question
-g ${PG_USER} ${PG_BINDIR}/postgres   # I have no clue what PG_BINDIR is or where to find it
-D ${PG_DATADIR}          # same thing with PG_DATADIR
-d 5                             # what is the d option/switch

Thanks, in advance!

Edit: Oh it looks like that is the command to run

sudo -u ${PG_USER} -g ${PG_USER} ${PG_BINDIR}/postgres -D ${PG_DATADIR} -d 5

Oh it looks like that is the command to run

@luismadrigal yes, those are all options and variables for manually running postgres inside of its docker container.

But can you please explain what these mean

These PG_* variables are defined in the postgres Dockerfile [1], so once you're at a shell inside the postgres container, they're available and ready to use. Type env | grep -i pg_ to print the environment variables for review.

${PG_USER} specifies both the process UID/GID the database service runs as.
${PG_BINDIR} holds a path to the directory where the postgres binary is located.
${PG_DATADIR} holds a path to where postgres stores database files.

And the -d 5 is a postgres option that sets the debugging level to 5 [2]. My intent here was to dump more information related to the tuple concurrently updated error into the server log file, but instead I found that the server ran without any problems, then I just methodically backed out to the composer utility, testing whether each tool between me and postgres might be causing the startup error (i.e. entrypoint.sh, docker compose).

[1]: https://github.com/sameersbn/docker-postgresql/blob/master/Dockerfile
[2]: https://www.postgresql.org/docs/9.4/static/app-postgres.html

This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings