Docker base image with PostgreSQL 10 released

> df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G     0  2.0G   0% /dev
tmpfs           396M   41M  355M  11% /run
/dev/vda1        58G   27G   32G  47% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda15      105M  3.4M  102M   4% /boot/efi
/dev/sda1       246G   56G  178G  24% /mnt/volume-fra1-01-part1
tmpfs           396M     0  396M   0% /run/user/0

Upgrading PostgreSQL from version 9.5 to 10
WARNING: Upgrading PostgresSQL would require an addtional 1.5M of disk space
Please free up some space, or expand your disk, before continuing.

So, is the issue with /dev/vda1?
If so, should a swap file help?
If not, what do I do next?

I tried to remove a backup, which was 1GB, but it didn’t help.

Hey, @meglio. I’m working on a script that will help debug this particular issue. Could you give me the output of these two commands?

  echo df -h / /var/discourse /var/lib/docker /var/lib/docker/* |uniq | tee >> $LOG_FILE
  sudo docker exec -w /var/www/discourse -i $YML df -h /shared /shared/backups /shared/uploads /shared/postgres_data /shared/redis_data |uniq

Also, I submitted this PR a while back that might help with this issue (though I’m not clear what your issue is at this point).

3 Likes

12 posts were split to a new topic: Upgrade of Postgres failed due to corrupted database?

echo df -h / /var/discourse /var/lib/docker /var/lib/docker/* |uniq | tee >> $LOG_FILE

Output:

-bash: $LOG_FILE: ambiguous redirect

@pfaffman

Hi @pfaffman, I just tried again now and the issue is the same - still can’t upgrade to PostgreSQL 10, it asks me for 2…10MB of free space.

Even after cleaning up with apt-get autocleanup, which freed ~800MB of space, it still asks me for 8MB of free space.

:/var/discourse df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G     0  2.0G   0% /dev
tmpfs           396M  5.7M  390M   2% /run
/dev/vda1        58G   31G   28G  53% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda15      105M  3.4M  102M   4% /boot/efi
/dev/sda1       246G   59G  175G  26% /mnt/volume-fra1-01-part1
tmpfs           396M     0  396M   0% /run/user/0
overlay          58G   31G   28G  53% /var/lib/docker/overlay2/efed3d1d9b0c613c0c33f0988390802d301cc0214d988a971da0f466d421d19d/merged
shm             512M  4.0K  512M   1% /var/lib/docker/containers/4ce1664f6c21aa8ccf7c69281f5b1a3e6d13d9d406b93a39241604bda0700e84/mounts/shm

Any ideas how to workaround?

I came up with an idea that I’m trying to implement, but have encountered a few obstacles.

I have a 250GB volume attached to the droplet. So I decided to create a folder: /shared/standalone/t and symlink it to a folder in the volume.

Next, I edited the postgres.template.yml and changed all references of /shared/postgres_data_new to /shared/t/postgres_data_new.

What I expect is that /shared/ of the container gets mounted to /var/discourse/shared/standalone/, and then when the postgres 9.5>10 upgrade process starts, it will create /var/discourse/shared/standalone/t/postgres_data_new, which in fact will be created at the 250G volume.

However, when the postgres upgrade process starts, it fails with the following error:

install: cannot create directory ‘/shared/t’: File exists

Why does it try to create a /shared/t directory, and not /shared/t/postgres_data_new. What am I missing in the postgres.template.yml file?

P.S. I also commented out the following section:

# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
         # required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))

         #if [ "$free_disk" -lt "$required" ]; then
         # echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
         # echo "Please free up some space, or expand your disk, before continuing."
         # echo ''
         # echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
         # exit 1
         #fi

UPD.

Finally, I succeeded upgrading Postgres from 9.5 to 10 with limited disk space.

So, here is how.

Upgrading PostgreSQL from 9.5 to 10 with limited disk space

So if your disk is e.g. 60GB and system + database takes 35GB, you won’t be able to update Postgres to the newer major version, as it requires free space that is 2x of the database space.

Here is a workaround that worked for me.

Step 1. Buy / mount a volume (this is only needed temporarily). Create a folder in the volume. In my case the folder name is t.

Step 2. Edit containers/app.yml and add a new volume:

- volume:
      host: /mnt/volume-fra1-01-part1/t
      guest: /shared/t

In this example, /mnt/volume-fra1-01-part is the path to the mounted volume. Change it to reflect yours.

Step 3. Backup your templates/postgres.template.yml file, then edit it:

Find path: /root/upgrade_postgres and comment out the following section:

# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
         # required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))

         #if [ "$free_disk" -lt "$required" ]; then
         # echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
         # echo "Please free up some space, or expand your disk, before continuing."
         # echo ''
         # echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
         # exit 1
         #fi

Also, change all references of:

  • /shared/postgres_data_new to /shared/t/postgres_data_new
  • /shared/postgres_data_old to /shared/t/postgres_data_old

(the /t/ is added to the path).

Step 4. Rebuild your Discourse instance:

cd /var/discourse
./launcher rebuild app

Step 5 Edit file app.yml and remove the volume we added previously. Restore the postgres.template.yml

Step 6. Rebuild your Discourse instance again.