Open milot-mirdita opened 3 years ago
I experienced the same problem. Thank you for the workaround, but I would hope for an official solution.
The code is still set to time out after 10 minutes when refreshing the snap. Here's how I worked around it.
backup the database manually:
sudo service snap.rocketchat-server.rocketchat-server stop
sudo service snap.rocketchat-server.rocketchat-mongo status | grep Active
time sudo snap run rocketchat-server.backupdb
sudo service snap.rocketchat-server.rocketchat-server start
If you need to restore the database:
sudo service snap.rocketchat-server.rocketchat-server stop
sudo service snap.rocketchat-server.rocketchat-mongo status | grep Active
sudo cp rocketchat_backup.tgz /var/snap/rocketchat-server/common/
time sudo snap run rocketchat-server.restoredb /var/snap/rocketchat-server/common/rocketchat_backup.tgz
sudo service snap.rocketchat-server.rocketchat-server start
Now before you refresh the snap of rocketchat-server:
snap get rocketchat-server
sudo snap set rocketchat-server backup-on-refresh=disable
snap get rocketchat-server
sudo snap refresh --channel=6.x/stable rocketchat-server
sudo snap set rocketchat-server backup-on-refresh=enable
snap get rocketchat-server
If the refresh to a newer version fails, you must refresh back to the version you had installed and then restore the database for that version. Don't restore the database when you're on a newer version.
Description:
I tried to upgrade a rocket chat server from 2.4.11 to 3.8.3. Snap would constantly fail with the following error:
htop
revealed thattar
was called bybackupdb
which would eventually be killed as the CPU is quite slow and gzip took too long.Digging in the snap source code revealed that it gets killed because the default snap timeout of 10 minutes is used: https://github.com/snapcore/snapd/blob/e96c9757cce0f552bf088ef9ed515f946bdb4849/overlord/hookstate/hookmgr.go#L461
As a workaround I created my own modified version of
backupdb
that changed thetar
invocation totar -I "gzip -1" -czvf ...
. And mounted my version of the script into the snap:Afterwards snap refresh worked without issues.
I only realized afterwards that I could have disabled the backup with
snapctl
andbackup-on-refresh
.Steps to reproduce:
snap refresh rocketchat-server
Expected behavior:
Don't fail on pre-refresh hook
Actual behavior:
Time out after 10 minutes, refresh doesn't complete.
Server Setup Information: