GitHub sync fails after updating GitHub teams in the org

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) SonarQube enterprise 10.5.1
  • how is SonarQube deployed: Docker
  • what are you trying to achieve: I used to have a GitHub App that configured manual triggering of synchronization with my GitHub teams. I have a use case that requires me to be able to recreate these teams, so the team ids will change. I think this means that, in the external_groups table, external_group_id will change. When I try to synchronize after one such recreation, I cannot complete the sync due to index uniqueness constraint. Is SonarQube using a basic insert for this command, and does it make sense to allow upserting to this table?
  • To recreate the issue:
    • I had a team in GitHub call team-a
    • I renamed that team to team-a-old
    • I created a new team-a
    • I triggered the SonarQube sync
    • I ran into the Unique Key constraint violation in SonarQube
  • Due to this fail, I am also unable to onboard new people to use SonarQube.

The error message is here:
Error querying database. Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.user.ExternalGroupMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Batch entry 0 insert into external_groups ( group_uuid, external_group_id, external_identity_provider ) values ( 'some_uuid', 'id', 'github' ) was aborted: ERROR: duplicate key value violates unique constraint "pk_external_groups" Detail: Key (group_uuid)=(some_uuid) already exists. Call getNextException to see other errors in the batch. ### The error may exist in org.sonar.db.user.ExternalGroupMapper ### The error may involve org.sonar.db.user.ExternalGroupMapper.selectByExternalIdAndIdentityProvider ### The error occurred while executing a query ### Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.user.ExternalGroupMapper.insert (batch index #1) failed. Cause: jav