Automated backups not being triggered because cannot allocate memory


(Yaw Anokwa) #1

Manual backups (local and to S3) work great, but automated backups don’t seem to work. Any ideas why?

Settings

Errors ~ 6 minutes after trigger

Job exception: Cannot allocate memory - fork(2)

/var/www/discourse/lib/backup_restore/backup_restore.rb:160:in `fork'
/var/www/discourse/lib/backup_restore/backup_restore.rb:160:in `start!'
/var/www/discourse/lib/backup_restore/backup_restore.rb:15:in `backup!'
/var/www/discourse/app/jobs/regular/create_backup.rb:8:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

Ram

root@discourse-app:/var/www/discourse# free -mh
              total        used        free      shared  buff/cache   available
Mem:           992M        664M         72M        137M        255M         50M
Swap:          2.0G        1.0G        1.0G

Notify if s3 backups are failing
(Rafael dos Santos Silva) #2

If you are constantly swapping 1GB, you need more memory on this server.


(Robby O'Connor) #3

you probably are big enough that more memory is needed…1GB is enough.


(Yaw Anokwa) #4

If it’s a RAM issue, why do manual backups work then?


(Robby O'Connor) #5

I’m not entirely sure but that error is due to insufficient memory available.


(Yaw Anokwa) #6

I upgraded from 1 GB to 2 GB box and backups seem to be working now.

              total        used        free      shared  buff/cache   available
Mem:           2.0G        1.2G        276M        141M        544M        498M
Swap:          2.0G         28M        2.0G

If anyone else has this problem, I’d try a reboot first because the Ubuntu box had also recently had kernel upgrades, so maybe that was the issue.


(Jay Pfaffman) #7

If you run discourse-setup it will tweak the memory settings to take advantage of the additional memory.


(Andrew Waugh) #8

Interesting - I didn’t realise that running discourse-setup could be done on an install which was already up and running.


(Yaw Anokwa) #9

Hmm. Running the setup again sounds dangerous to my existing app.yml. Any idea what the tweaks are?


(Yaw Anokwa) #10

I answered my own question :joy:. According to discourse_docker/discourse-setup at master · discourse/discourse_docker · GitHub, the tweaks to app.yml are:

# db_shared_buffers: 128MB for 1GB, 256MB for 2GB, or 256MB * GB, max 4096MB
# UNICORN_WORKERS: 2 * GB for 2GB or less, or 2 * CPU, max 8