Closed TomLewis closed 6 years ago
Another issue, the ID's are not incrementing properly 1,2,3.. mine started 1,8,12??
Could you try letting TokenManager create the table instead of using the queries I've listed? I do not have extensive knowledge with sql, so the queries might have caused the issue.
@RealizedMC I did that directly after posting this issue, same exact same problems, so its a fresh install. The difference being that. As you can see from this Screenshot there are 104 rows from people that have logged in, and both the ID is complete wrong and im still getting the dupe errors for each user in chat.
Looking at your schema structure, you have UUID set to unique, and this happens on first log-in when they have no records already available, so its happening on the initial phase when their first initial balance is setup you are running the insert query more than once, as its being put in and then since its unique its throwing errors since you are trying to insert more rows with the same unique UUID. As for your ID, you do not need to put in any value into ID to increment, it will automatically increment.
I've inspected my code and there is really no issue regarding duplication, which really confuses me. (I've also tested on localhost, no issues after letting TokenManager generate a new table)
Maybe try using a different table name?
I've just found this post about how it could be a bug with MySQL, is yours up-to-date?
Yes I updated my entire system yesterday, I did a massive maintenance update for my OS & Server and plugins, hence me testing it out.
Server version: 10.1.32-MariaDB-1~jessie
I have been running a MySQL server for years, I have many plugins using MySQL, Im sure I would have had other issues from other plugins a very long time ago if it was that.
I don't know Java, but i do know SQL, so I scanned your code quickly and found this https://github.com/RealizedMC/TokenManager/blob/6a5a65c1ebe354f8ad623375a5a4c4f34f0c5e0a/src/main/java/me/realized/tokenmanager/data/database/MySQLDatabase.java#L429-L434
That doesn't make much sense being run at once all together? Surely you would only need to update or insert when you needed to do those things, and the same for creating the table at first run only.
INSERT_OR_UPDATE is only used for bulk inserts when transferring from flatfile to mysql. It seems like you’re using MariaDB, and since I’ve only tested my code on InnoDB, I’ll test on that and tell you the results.
Just so you know its industry standard now to use MariaDB over MySQL, Debian 9 actually replaces MySQL with MariaDB by default. https://www.debian.org/releases/stable/amd64/release-notes/ch-whats-new.en.html#mariadb-replaces-mysql
As for that cluser of SQL, I search or find any other instances where you run SQL to update/insert, does Java have its own methods for updating tables without using actual SQL in the code?
Nope, in MySQLDatabase queries are specified in the methods #update and #insert, and those methods are called in multiple places in the class.
Finished testing, no issues. Have you tried specifying a different table name yet?
I created a new table and tested it from a different server, same database (as I cant reboot my live production) and it seems to be fine? why is this? its the exact same Schema, identical. This other server is a older version of Paper spigot tho, are you testing on the latest build of paperspigot?
I will have to test it on my main production server later when its not so busy.
It isn't an issue with spigot, since it's the query returning the error. My guess is something related to the old table is still remaining on your db. Please let me know the results when you test on your main server.
Update on Production server, it seems to be fine!? This makes absolutely no sense to me at all! well, at least its working, Super confused the tables are identical. Very strange.
I updated token manager to the latest 3.0.4, and I emptied my tokens database and run what you said on #3 to give us a unique ID to make sure my schema was updated. Now whenever anyone logs in for the first time to populate their token into the database (Mines set at 0 as default) They get spammed the message: "Failed to load your token balance: Duplicate entry.." then their UUID. which is impossible as the table was emptied, nothing in it. Second issue is, why the hell is this message being shown to users? I have users panicked at me now, like they are scared there is a major issue, this should be sent to OPS/Perm Staff only.