And here it is.
1. Create a badge (with image).
2. Set this badge for 2 roles.
-> error message
user warning: Duplicate entry '2-11-role' for key 1 query: INSERT INTO user_badges_user (uid, bid, type) (SELECT uid, 2, 'role' FROM users_roles WHERE rid=13) in .../sites/all/modules/user_badges/user_badges.module on line 612.
"There was a problem saving roles to the database"
- "REPLACE INTO" (only on mysql, I know..), or
- "INSERT ... ON DUPLICATE KEY UPDATE" (cross-db compatible?), or
- check if the table rows already exist, and add only those that are missing yet, or
- wrap the stuff in a try/catch block, and just ignore the warnings.. (didn't think much about that, actually)