push registration fix #2
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/push-one-session-many-registrations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Half of QA gets no iOS pushes. The apushd log (prod, 2026-10-31) shows, for those devices, only their PushKit tokens (
anotherimIOSVoipprod/anotherimIOSVoipdev) and not a single push to the alert module of the same device.The iOS app registers two push targets: the APNs alert token and the PushKit token. libtacky sends both
enables in one c2s session, on purpose (push.tcl: "the server correlates them by session id").Stock ejabberd 26.09
mod_pushkeeps one registration per session. A registration's id is the session's timestamp, so both rows share it, and that breaks:mod_push_keepalive, is pushed throughnotify(State, …)→lookup_session(U, S, ID). It reaches one registration only: the one in the{U, S, ID}cache, i.e. the last enabled. When that is PushKit's, every message is dropped (apushCalls=only) and the alert token gets nothing.cache_life_time, a restart),mod_push_mnesia:lookup_session/3matches only[Rec] | []. With two rows it fails (case_clause) and nothing is pushed at all.mam_message→drop_online_sessions) leaves out every registration whose id is a live session's, both of them, while the session is held.delete_sessiondeletes by id: an App Server's refusal of one token, or anotherenableof one node, deletes both.Which half works depends on which token was enabled last in the session, and on whether the session was held or closed: a closed session goes through the offline/archive path, which looks up all registrations and works.
mod_apush's tests never caught it: they register PushKit and the phone from different resources, i.e. different sessions.Fix
Fixed in
mod_apush, one place, for every app build already out (no client change):enablein a session that already has an apush registration of another node with the same App Server is not passed tomod_push.mod_apushanswers it and keeps it as a sibling of the session's registration, in Mnesia (apush_sibling, disc copies, a bag per account). The node's registrations from other sessions are deleted, asmod_pushdoes for its own.mod_pushsends to the session's own registration also goes to its siblings, throughmod_push:notify/7. That covers every path alike: pending, archive, offline and the keepalive's wake-up. Each sibling is decided as a registration of its own: its calls, its window and its trailing push.waitdrops that sibling alone.disableof a sibling's node is answered bymod_apush.mod_pushwould have turned push off for the whole session.remove_userclears the account's siblings.Known limit:
mod_client_accessdoes not list a sibling. A revoke ends the sibling's pushes together with its primary registration.Tests
one_session: both tokens enabled from one session.mod_push's cache cleared.mod_push.remove_userclears the siblings.one_session_window: the sibling has its own window and trailing push; refused for good it is dropped, refused withwaitor taken it is kept.one_sessionfails on master: the message is pushed nowhere, which is the prod bug.Checked: the suite on ejabberd 26.09's own release (the arm64 .deb unpacked, eunit from OTP maint-28,
build-modules.sh's steps): all 43 tests pass,mod_apush99.8 % of 460 lines covered.make test(the docker build) was not run here.After deploy
anotherimIOSprod/anotherimIOSdevpushes should appear for the devices that showed only VoIP modules.kind=messageon the VoIP modules, whichmod_apushshould already drop forapushCalls=only. If that persists, apush_sessiondump from prod is needed.Reviewed and merged into master as
3a0b477, on top of fix/push-dead-session (2b532d9: the unacked check, registrations kept clean, the ack_kind crash fix), which prod's mod_apush already runs. The merge keeps your design unchanged; what the resolution adds:bind_enablerunsreplace/4(the same install's earlier token under another node dropped from mod_push's) and thenenable_sibling/2.push_send_notificationkeeps theis_away/is_push_servicegates and mirrors to the siblings before deciding the primary.enable_sibling's stale rule also drops a sibling of the same install (sameapushResourceandpushModuleunder another node), so a rotated token in one session does not leave two siblings of one module.Known edge left as is: a primary re-enabled under a new node in the same session orphans its sibling until the next enable.
make test: all 129 tests, mod_apush 99.6 % of 562 lines. fix/push-siblings (the lookup by resource) is superseded and not merged. Prod deb: ejabberd-mod-apush_0~20261031.3a0b477 in /data/another-releases/push-2026-10-31.Closing: merged into master as
3a0b477(see above).Pull request closed