can't use mnesia database after 17.04->17.06 or 17.07 upgrade: node name mismatch

After upgrading from 17.04 to 17.06 (or 17.07 for that matter) ejabberd no longer starts. In the log it complains about a node name mismatch. I'm using a non-default node name.
Usually when I upgrade, I perform the upgrade, change the node name in ejabberdctl's config, set up some other stuff (ports, mainly) and restart ejabberd. That's what I've done this time, too, but it does not work. Any suggestions? I've already tried to backup the database and restore it but without luck. I do have a working backup.

I imagine, what I will

I imagine, what I will mention now you have already think it, but let's make sure:

In ejabberdctl.cfg in my ejabberd 17.07, that works perfectly, I changed ejabberd@localhost to ejabberd11@localhost (which surely will provoke problems). Then, when starting ejabberd, it complains as expected:

16:51:28.582 [critical] Node name mismatch: I'm [ejabberd11@localhost],
 the database is owned by [ejabberd@localhost]

The simple solution is to replace in the cfg file the node mentioned in "I'm NODE" with the one mentioned in "owned by NODE". I say this because, maybe you are switching them the other way?

Yes, that is what I am doing.

Yes, that is what I am doing. My ejabberdctl says ERLANG_NODE = ejabberd_foo@localhost (which is just the same like starting ejabberd by ejabberdctl --node ejabberd_foo@localhost). The thing is this has always worked, and if I remember correctly it is necesarry on my system as it is a shared environment and other people are using instances of ejabberd, too. Anyway I cannot simply change the node name to ejabberd@localhost, because then users no longer can log in.

Ok, so I figured it out, but

Ok, so I figured it out, but I'm not sure if this is the way it should be? The way to fix this, is to delete the database directory, starting ejabberd, stopping it and then restoring the backup. So 1) update ejabberd 2) remove database folder 3) start ejabberd with different node name 4) restore backup. Weird, that was easier in previous versions.

EDIT: Nope, sorry. This is obviously not what I did, I must have done something subtly different, because these steps don't work, either.

EDIT2: OK, this is very weird, maybe it's a bug. When I change the ERLANG_NODE in ejabberdctl's config, it does not work, when I change the default value it in ejabberdctl itself it does (that's the subtle difference, I did not set the ERLANG_NODE via the config but in the script itself).

Maybe the configuration file

Maybe the configuration file you are modifying is not the one read by ejabberd? If you change any other option in that file, does it take effect, or does it have the same problem that ERLANG_NODE?

Yes, I checked this. The

Yes, I checked this. The server started before I changed the config file. I have filed a bug describing the problem in detail: https://github.com/processone/ejabberd/issues/1847

Syndicate content