As additional infos, can you check if you have duplicated secrets in your database:
SELECT s.resource_id, s.user_id, min(s.modified) as min_modified
FROM secrets s
GROUP BY s.user_id, s.resource_id
HAVING count(*) > 1
Can you also check the permissions for deleted users ?
select *
from permissions p
where p.aro_foreign_key IN (
select u.id
from users u
where u.deleted = 1
OR u.active = 0
);
Best regards,