Currently, concurrent request to create a group and group-users mapping is causing duplicate entries of the same group in the x_group table and user-group mapping entry in the x_group_users table. Duplicate entry creation has been restricted through the
RANGER-1765 patch which creates unique constraints on the x_group and x_group_users table. But unique index creation may fail if there is already duplicate entries(likely to happen in upgrade case) so we should delete duplicate entries of these tables before creating the unique index. If the reference of duplicate group id is being used in child table then the id of the duplicate group shall be updated in the child table. In case of duplicate entries of the same group name; group name having the minimum id(created first) shall be given higher preference and will not be deleted from the x_group table.