# Group\_edges are orphaned when group admin deletes account

**URL:** <https://forum.heroiclabs.com/t/group-edges-are-orphaned-when-group-admin-deletes-account/6550>\
**Category:** Runtime Framework\
**Tags:** server-framework, golang, groups\
**Created:** [May 14, 2026, 8:43am UTC](https://forum.heroiclabs.com/t/group-edges-are-orphaned-when-group-admin-deletes-account/6550 "2026-05-14T08:43:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wlucjan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/wlucjan/32/2662_2.png) [@wlucjan](https://forum.heroiclabs.com/u/wlucjan)\
**Post date:** [May 14, 2026, 8:43am UTC](https://forum.heroiclabs.com/t/group-edges-are-orphaned-when-group-admin-deletes-account/6550/1 "2026-05-14T08:43:19Z")

</div>

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.go`which uses following query to delete edges:

```sql
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.

1. Versions: Nakama 3.34.1 (but noticed in latest code in repo as well)
2. Server Framework Runtime language Go

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [June 12, 2026, 12:51pm UTC](https://forum.heroiclabs.com/t/group-edges-are-orphaned-when-group-admin-deletes-account/6550/2 "2026-06-12T12:51:58Z")

</div>

Hi @wlucjan,

Thank you for reporting, we’ll look into this.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [July 6, 2026, 3:45pm UTC](https://forum.heroiclabs.com/t/group-edges-are-orphaned-when-group-admin-deletes-account/6550/3 "2026-07-06T15:45:47Z")

</div>

This has been fixed and will be part of the next Nakama release which should happen within the next couple of weeks.
