Matrix-Synaps Start Error: role "matrix-synapse" does not exist After Upgrade

Hello! I’m having an issue starting the matrix-synapse package after upgrading to 22.05. I’m getting the following error:

Oct 22 10:10:39 pacifica synapse_homeserver[1280]: **********************************************************************************
Oct 22 10:10:39 pacifica synapse_homeserver[1280]:  Error during initialisation:                                              
Oct 22 10:10:39 pacifica synapse_homeserver[1280]:     connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "matrix-synapse" does not exist
Oct 22 10:10:39 pacifica synapse_homeserver[1280]:             
Oct 22 10:10:39 pacifica synapse_homeserver[1280]:  There may be more information in the logs.                                
Oct 22 10:10:39 pacifica synapse_homeserver[1280]: **********************************************************************************

I looked at the 22.05 manual and it includes a section with a services.postgresql.initialScript stanza. This stanza wants you to create a role and db titled matrix-synapse.

This is either new or I just missed it when I setup my Matrix server. My database and user/role names are different.

Is there something I can do to configure synapse to use a different name/role? Here’s my current services.matrix-synapse.settings.database_args section:

database_args = {
  database = "clever_db";
  user = "clever_db_user";
  password = "sooperSneaky";
  host = "localhost";
};

No, it’s not something new: I think those defaults have never been changed.
What changed recently was moving most of the options to matrix-synapse.settings. Maybe you have been using custom user/roles and lost those settings while upgrading?

Also, be careful that the default media store path has been changed from /var/lib/matrix-synapse/media to /var/lib/matrix-synapse/media_store. If you don’t rename the directory before starting matrix-synapse chaos will ensue.

These are very helpful tips, thank you!

I did look over those upgrade notes and moved my db settings under the new settings level. Here’s what it looks like:

{
  services.matrix-synapse = {

    enable = true;

    settings = {
      server_name = "destrocodpiece.wtf";
      database_args = {
        database = "some_db";
        user = "some_db_user";
        password = "sooperSneaky";
        host = "localhost";
      };
...

I thought that moving database_args under services.matrix-synapse.settings would cause them to be added to homeserver.yaml but I guess that’s not true. Where should I put these custom arguments now?

Yes, that’s the problem: it’s settings.database.args, not settings.database_args.

    settings = {
      server_name = "destrocodpiece.wtf";
      database.args = {
        database = "some_db";
        user = "some_db_user";
        password = "sooperSneaky";
        host = "localhost";
      };

nixos-rebuild should have warned you with something like this:

The option `database_args.database' can no longer be used since it's been removed.
Use settings.database.args.database instead

However it couldn’t catch this typo because matrix-synapse.settings allows
arbitrary values to be set. This has both pros and cons, unfortunately you got
to experience the bad part, sorry about that.

I would have expected synapse to throw some warnings, though.

1 Like

Ahh, thank you! I renamed the content folder and change that underscore to a period and now it works!

I think it’s pretty obvious I’m still learning some of the basics of NixOS. I tried looking at the source of the matrix-synapse derivation for some guidance here but didn’t find anything:

Is these somewhere I could have gone to see that I needed database.args instead of database_args?

1 Like

Next time, try running nixos-rebuild build without touching the configuration. You should get a list of warnings/errors telling you which options have been removed/renamed and how to upgrade. After having fixed those errors you can finish by checking the release notes.

Also, .settings options corresponds 1:1 to the original settings names, so you could have looked at the matrix-synapse documentation, in this case.

1 Like

This is very helpful. Thanks again!