Skip to content

MAM silently fails if MUC uses one domain for multiple hosts #4568

@erebion

Description

@erebion

Environment

  • ejabberd version: 26.04
  • Erlang version: Eshell V16.3.1
  • OS: Linux (Debian)
  • Installed from: official deb

Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml

  mod_mam:
  ##   ## Mnesia is limited to 2GB, better to use an SQL backend
  ##   ## For small servers SQLite is a good fit and is very easy
  ##   ## to configure. Uncomment this when you have SQL configured:
    db_type: sql
    cache_life_time: 240d
    default: always
    assume_mam_usage: true
  mod_muc:
    host: tardis.erebion.eu 
    access:
      - allow
    access_admin:
      - allow: admin
      - allow: components
    access_create: muc_create
    access_persistent: muc_create
    default_room_options:
      anonymous: true
      mam: true
      public_list: false
    max_users: 1000000

Errors from error.log/crash.log

No errors!

Bug description

Two virtual hosts are configured:

  • erebion.eu (main virtual host)
  • ejabberd.erebion.eu (mainly used for testing the Matrix GW and other modules before I use them with the main virtual host)

MUC is hard-coded to use tardis.erebion.eu

MAM requests lead to:

<!-- Outgoing Wed Apr 22 00:38:17 2026 (erebion) -->
<iq to="[email protected]" type="set" xmlns="jabber:client" id="9e953dfa-2323-49c9-957e-49d18b1b2d58">
  <query xmlns="urn:xmpp:mam:2">
    <x xmlns="jabber:x:data" type="submit">
      <field type="hidden" var="FORM_TYPE">
        <value>urn:xmpp:mam:2</value>
      </field>
    </x>
  </query>
</iq>

<!-- Outgoing Wed Apr 22 00:38:17 2026 (erebion) -->
<r xmlns="urn:xmpp:sm:3" />

<!-- Incoming Wed Apr 22 00:38:17 2026 (erebion) -->
<a h="501" xmlns="urn:xmpp:sm:3" />

<!-- Incoming Wed Apr 22 00:38:17 2026 (erebion) -->
<iq xmlns="jabber:client" xml:lang="en" to="[email protected]/gajim.B2V5ANPR" from="[email protected]" type="result" id="9e953dfa-2323-49c9-957e-49d18b1b2d58">
  <fin complete="true" xmlns="urn:xmpp:mam:2">
    <set xmlns="http://jabber.org/protocol/rsm">
      <count>0</count>
    </set>
  </fin>
</iq>

Note that there are messages in the database.

Database:

MariaDB [ejabberd]> select server_host from archive where username='[email protected]' limit 1;
+---------------------+
| server_host         |
+---------------------+
| ejabberd.erebion.eu |
+---------------------+
1 row in set (6.285 sec)

MariaDB [ejabberd]> 
  • This should be set to erebion.eu, but instead is set to ejabberd.erebion.eu, which is incorrect.
  • This virtual host was never part of this MUC, it has never had a user joined! It should not show up in connection to this MUC.

Expected behaviour:

  • No silent breakage.
  • The database should not contain an incorrect value.
  • Perhaps there should be an error, if a hard-coded MUC domain cannot be used for multiple virtual hosts

This was found out during debugging with @weiss in the ejabberd MUC. (Thanks a lot!)

Non dev perspective:

  • I learned that I cannot use one hard-coded domain for both virtual hosts
  • However, MAM should not silently fail by returning a count of "zero messages available"
  • It shouldn't save database entries with the wrong host. Perhaps there should be an error explaining that this configuration does not work and just exit.
  • I'm not entirely sure how this would be solved best, but currently this is hard to track down for someone who like me is not an ejabberd dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions