To prevent users in an unconsistent state due to a failed rename in some step the following aproach can be used:
Marking the "old" and "new" users as being in a rename operation by the session that issues the rename.
If the rename fails in some step, try the best to return the users to their state before the rename operation.
If some user is left in an unconsistent state a cleaning routine grabs users marked with a dead session and tries to return them to their state before the rename operation.
To prevent users in an unconsistent state due to a failed rename in some step the following aproach can be used: