bob7l / HawkReloaded

19 stars 28 forks source link

Issue with Duplicated entry on inserting players into the database #66

Closed bob7l closed 8 years ago

bob7l commented 8 years ago

Error location: https://github.com/bob7l/HawkReloaded/blob/master/src/uk/co/oliwali/HawkEye/database/DataManager.java#L132

SQL: INSERT INTO hawk_table (player) VALUES (?) ON DUPLICATE KEY UPDATE player=VALUES(player)

Error: com.mysql.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'usernamePlaceholder' for key 'player'

How to reproduce: Unknown. If you login as an existing username with another case (Such as changing S to s), then the key will be considered a duplicate and the UPDATE query will be ran. I haven't been able to reproduce this error on MySQL 5.7

I believe this is due to a bug with MySQL. Attempting to update a unique key "ON DUPLICATE KEY" appears to arise issues on some rare occasions with a few users. My guess is it's attempting to replace the prior username with the new username, but since the prior username already exists within the database, it's unable to do so? Could this possibly be a concurrency issue internally?

bob7l commented 8 years ago

Fixed https://github.com/bob7l/HawkReloaded/commit/01f7ea77ff790af04072513b065f1874a6336abe