This could hang by getting a new pid from the sup then an old pid from Mnesia. Rewrite to be simpler and only have one source of truth.