I have encountered an issue, where superadmin could not leave a group he was in with error: failed to leave clan: user is last group superadmin
In Nakama console everything looked fine - group had only single member and edge count of 1. But in database I found orphaned group_edge for some deleted accounts that had been in admin role (state = 1)
Analyzing Nakama source coude I found, that group_edge has no cascades on foreign keys, and that deletion is done by application. In case of admin it goes with deleteRelationship function on line 2066 in core_group.gowhich uses following query to delete edges:
DELETE FROM group_edge WHERE ( (source_id = $1::UUID AND destination_id = $2::UUID AND state > 1) OR (source_id = $2::UUID AND destination_id = $1::UUID AND state > 1) ) RETURNING state
That means it will delete only users with states 2, 3 and 4 - respectively member, join request and banned. But will leave admin edges orphaned, therefore locking last remaining superadmin from leaving the group.
- Versions: Nakama 3.34.1 (but noticed in latest code in repo as well)
- Server Framework Runtime language Go