YunoHost-Apps / mautrix_signal_ynh

Matrix signal package for YunoHost
GNU Affero General Public License v3.0
4 stars 10 forks source link

Mautrix signal bridge service doesn't start after upgrade #101

Closed CodeShakingSheep closed 5 months ago

CodeShakingSheep commented 6 months ago

Describe the bug

After upgrading Mautrix signal app the bridge service doesn't start up successfully.

Log 1 I could fix the error message in Log 1 by running chown -R mautrix_signal:mautrix_signal mautrix_signal/ from /var/log. This worked. Previously the folder was owned by root:root.

Log 2 It states that I need to upgrade from version 0.4.2 to version 0.4.3 first before I can upgrade to version 0.6.1. I would have wished for a pre-upgrade warning about this. So, this means I need to restore the old version and then upgrade to this commit 53823e7d92a678c5c27f62f64f7e914bd7096d0d . Is there a way to do that with the yunohost upgrade command? Thanks.

Restore Edit: Restore doesn't work either :-| So, now I'm left without a signal bridge at all. Here is the log: https://paste.yunohost.org/raw/layocikeje The problem seems to be that database "matrix_synapse" doesn't exist. I checked this on my server and it's true. There's only a postgre SQL database "synapse" available. How can I fix that in the restore script? Edit 2: This seems to be the change in synapse app which isn't reflected in mautrix_signal restore script: https://github.com/YunoHost-Apps/synapse_ynh/blob/master/scripts/upgrade#L194

Adopt restore script in backup Edit 3: I could successfully restore the app by changing this line https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/76a4622e4a2226953d9811ec6b9d2a77bf71cd34/scripts/restore#L43 from synapse_db_name="matrix_$synapse_instance" to synapse_db_name="$synapse_instance" in the backup. Afterwards the restore was successful.

However, afterwards the service stopped again with another error PermissionError: [Errno 13] Permission denied: 'config.yaml'. I could solve this by running chown mautrix_signal:mautrix_signal config.yaml from /opt/yunohost/mautrix_signal. Previously the folder was owned by root:root.

Upgrade to version 0.4.3~ynh2 With command sudo yunohost app upgrade mautrix_signal -u https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/53823e7d92a678c5c27f62f64f7e914bd7096d0d --debug I could successfully upgrade to version 0.4.3. However, afterwards the error from log 1 was present again which could be solved with chown again. Messages get sent successfully but no messages are received.

Upgrade from version 0.4.3~ynh2 to version 0.6.1~ynh1 After upgrading again to the latest version, I receive the same error as in Log 2 FTL Failed to initialize database error="failed to run upgrade v11->v12: please upgrade to mautrix-signal v0.4.3 before upgrading to a newer version" db_section=main although this is exactly what I did?!? Seems to come from here https://github.com/mautrix/signal/blob/main/database/upgrades/upgrades.go#L34 .

So, I'm stuck now with version 0.4.3~ynh2. Can anybody help at this point? Any way I can trigger the DB upgrade manually?

Context

Steps to reproduce

I just hit the upgrade button in the webadmin. Although it says the upgrade has been successfull, a couple of seconds afterwards, the service stops.

Expected behavior

Mautrix signal bridge should start up successfully after upgrade.

Logs

Log 1:

May 26 18:10:35 systemd[1]: Stopping Matrix Signal Bridge...
May 26 18:10:35 python3[3427]: [2024-05-26 18:10:35,653] [INFO@mau.init] Everything stopped, shutting down
May 26 18:10:46 systemd[1]: mautrix_signal.service: Succeeded.
May 26 18:10:46 systemd[1]: Stopped Matrix Signal Bridge.
May 26 18:10:46 systemd[1]: mautrix_signal.service: Consumed 57.975s CPU time.
May 26 18:11:04 systemd[1]: Started Matrix Signal Bridge.
May 26 18:11:04 mautrix-signal[2284450]: Failed to initialize logger: failed to parse config for writer #2: can't open new logfile: open /var/log/mautrix_signal/mautrix_signal.log: permission denied
May 26 18:11:04 systemd[1]: mautrix_signal.service: Main process exited, code=exited, status=12/n/a
May 26 18:11:04 systemd[1]: mautrix_signal.service: Failed with result 'exit-code'.

Log 2:

May 26 18:22:34 systemd[1]: Started Matrix Signal Bridge.
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z INF Initializing bridge built_at="May 16 2024, 13:27:50" go_version=go1.22.2 name=mautrix-signal version=0.6.1
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z INF Initializing libsignal version:0.44.0 component=libsignal file=rust/bridge/ffi/src/logging.rs line=107 target=signal_ffi::logging
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z INF Bridge initialization complete, starting...
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z INF Preparing to update database schema current_version=11 db_section=main latest_known_version=20 oldest_compatible_version=11
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z INF Upgrading database db_section=main description="Unsupported version" from=11 single_txn=false to=12
May 26 18:22:34 mautrix-signal[2290702]: 2024-05-26T18:22:34Z FTL Failed to initialize database error="failed to run upgrade v11->v12: please upgrade to mautrix-signal v0.4.3 before upgrading to a newer version" db_section=main
May 26 18:22:34 systemd[1]: mautrix_signal.service: Main process exited, code=exited, status=15/n/a
May 26 18:22:34 systemd[1]: mautrix_signal.service: Failed with result 'exit-code'.

Log from restore https://paste.yunohost.org/raw/layocikeje

Log after restoring 0.4.2~ynh1:

May 27 03:27:37 python3[2559285]: Traceback (most recent call last):
May 27 03:27:37 python3[2559285]:   File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
May 27 03:27:37 python3[2559285]:     return _run_code(code, main_globals, None,
May 27 03:27:37 python3[2559285]:   File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
May 27 03:27:37 python3[2559285]:     exec(code, run_globals)
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix_signal/__main__.py", line 146, in <module>
May 27 03:27:37 python3[2559285]:     SignalBridge().run()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/util/program.py", line 91, in run
May 27 03:27:37 python3[2559285]:     self._prepare()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/util/program.py", line 97, in _prepare
May 27 03:27:37 python3[2559285]:     self.preinit()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/bridge/bridge.py", line 112, in preinit
May 27 03:27:37 python3[2559285]:     super().preinit()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/util/program.py", line 117, in preinit
May 27 03:27:37 python3[2559285]:     self.prepare_config()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/bridge/bridge.py", line 141, in prepare_config
May 27 03:27:37 python3[2559285]:     self.load_and_update_config()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/util/program.py", line 154, in load_and_update_config
May 27 03:27:37 python3[2559285]:     self.config.load()
May 27 03:27:37 python3[2559285]:   File "/opt/yunohost/mautrix_signal/lib/python3.9/site-packages/mautrix/util/config/file.py", line 36, in load
May 27 03:27:37 python3[2559285]:     with open(self.path, "r") as stream:
May 27 03:27:37 python3[2559285]: PermissionError: [Errno 13] Permission denied: 'config.yaml'
MayeulC commented 6 months ago

Hello @CodeShakingSheep , thank you for the report. Do you confirm that #102 allows you to upgrade from 0.4.3?

I'll try to have a look in a few hours.

TiberiusRegenschein commented 6 months ago

Similar error message on a NUC X86.

Error message: Mai 29 21:28:51 systemd[1]: Started Matrix Signal Bridge. Mai 29 21:28:51 mautrix-signal[1490532]: Failed to initialize logger: failed to parse config for writer #2: can't open new logfile: open /var/log/mautrix_signal/mautrix_signal.log: permission denied Mai 29 21:28:51 systemd[1]: mautrix_signal.service: Main process exited, code=exited, status=12/n/a Mai 29 21:28:51 systemd[1]: mautrix_signal.service: Failed with result 'exit-code'.

I am on Synapse version 1.107.0~ynh1 and Mautrix signal bridge version 0.6.1~ynh1

For me upgrade seems to work and I assume changing ownership should do the trick