We expose a service that allows clients to create a MUC room in Ejabberd with a given expiry time. After this time, the room should be destroyed, regardless of whether the room is active.
We currently achieve this by:
- Setting custom expiry time metadata in the room options when creating a room.
- Running a cronjob that queries Ejabberd for all online room names, queries each of these names for their rooms options, and requests that the room is destroyed the expiry is up.
This approach is very naive and, as the number of rooms grows, we see the list online rooms admin call fail at an increased rate with the following error:
2021-04-28 15:24:57.011582+00:00 [error] REST API Error: muc_online_rooms_by_regex([{<<"regex">>,<<".*">>}, {<<"service">>, <<"ourchatservice">>}]) -> error:{badmatch, {error, notfound}} [{mod_muc_admin, get_room_config, 1, [{file, "src/mod_muc_admin.erl"}, {line, 814}]}, {mod_muc_admin, build_summary_room, 3, [{file, "src/mod_muc_admin.erl"}, {line, 394}]},
We suspect the list error is probably related to the large volume of MUC rooms we are working with - in the tens of thousands - and we are looking for a way we can support this feature without expensive operations like listing all online rooms.
I wonder why using muc_online_rooms_by_regex with a regex as useless as .* instead of simply using muc_online_rooms...
The rooms have a very strict and definitive expiry time, like replicants in Blade Runner, that not even their god can extend their life?
In that case, you can include that expiry time in the own room name, so that you don't need to query rooms details: the room name itself would say when the room should be destroyed:
[email protected]
In that case, it would make sense to use muc_online_rooms_by_regex to list rooms that have in the room names the expiry date of today, or previous days.