It is possible to create 2 groups with the same name in the same course if they use different case. For exemple we could have the groups "Uber" and "UBER". Then in a course that has such groups we can add an instance of the module mod_assign. The students of the course do their assignment and then the couse is backuped.
If we try to restore the course there will be a database write error on the table mdl_assign_submission because of a duplicate entry on a key made of the fields assignment, userid, groupid and attemptnumber, the error being on the groupid field. What I think is happening is that since we have 2 groups that have similar names, the groupid we get for the 2 groups will be the same and will cause a duplicate entry.
The database write error happen in the function process_assign_submission but the problem may be the groupid returned by the function get_mappingid('group', $data->groupid). As I said at this point the groupid returned will be the same for the 2 differents groups.
Perhaps there is something to be fixed in the way get_mappingid works so that it return the right groupid when many groups have names differing only by the case.