Scenario: This error occurs when trying to change a User's username to one that already exists in any Salesforce org globally (not just your org
If you are updating user object records using apex class which implements PostCopyScript interface during Sandbox Refresh it may result in below Duplicate Username exception.
EXCEPTION_THROWN|[50]|System.DmlException: Update failed. First exception on row 0 with id 005***************; first error: DUPLICATE_USERNAME, Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). : [Username]
This can happen post refresh. Usually the sandbox copy takes time to go through replication of user records, which is 48 hours.
This is working as designed. As a workaround -
2. If apex class script doesn't work then can raise a Support case to further review this.
NOTE - This process takes maximum 48 hours so after that issue is expected to be resolved.
000381924

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.