TheNewEconomy / EconomyCore

The core code powering TNE.
Other
19 stars 5 forks source link

[BUG]: SQLIntegrityConstraintViolationException #73

Closed dentatar closed 11 months ago

dentatar commented 11 months ago

TNE Version

0.1.2.5

Spigot Version

Paper 1.20.1

Your config.yml

https://pastebin.com/mkpdHPk3

Your latest server log

https://pastebin.com/PqdLbQyn

What modules are you using?

No response

What part of TNE is the bug affecting?

Transactions

Is your server using online mode?

Yes

Bug description

Apparently everything is working fine but every 10 mins my logs are flooded with that error, stack trace attached. Transactions between players are not generating this error, only autosaves.

How to reproduce

I have TNE installed on 2 of my servers, connected to the same mysql and redis. Configs are exactly the same (even the names, or else balances would split between servers), only server uuids are differ. One of my servers also have Towny installed. Transactions between players and across servers are working fine, there just wasn't a suitable category for this error :)

creatorfromhell commented 11 months ago

TNE Version

0.1.2.5

Spigot Version

Paper 1.20.1

Your config.yml

https://pastebin.com/mkpdHPk3

Your latest server log

https://pastebin.com/PqdLbQyn

What modules are you using?

No response

What part of TNE is the bug affecting?

Transactions

Is your server using online mode?

Yes

Bug description

Apparently everything is working fine but every 10 mins my logs are flooded with that error, stack trace attached. Transactions between players are not generating this error, only autosaves.

How to reproduce

I have TNE installed on 2 of my servers, connected to the same mysql and redis. Configs are exactly the same (even the names, or else balances would split between servers), only server uuids are differ. One of my servers also have Towny installed. Transactions between players and across servers are working fine, there just wasn't a suitable category for this error :)

This is caused by removing data from the users table, but not from the holdings table. Youd have to find the user that was removed from the table and not the others. Not sure if you went in and deleted someone from the table or not but that's what causes this.

dentatar commented 11 months ago

Hm i also thought about that, but couldn't find any… This is especially strange because accounts table even have more ids than holdings table 🤔

creatorfromhell commented 11 months ago

Hm i also thought about that, but couldn't find any… This is especially strange because accounts table even have more ids than holdings table 🤔

That's definitely the error though, something got deleted in the SQL. I don't know again if you manually deleted something but that's the only real way it happens in TNE.

creatorfromhell commented 11 months ago

Essentially it's trying to add or update the holdings for an account that doesn't exist in the accounts table. This could really only happen if someone deleted a user entry from the accounts table while the server was running. Since it's try to update the holdings from the cache. So you could try stopping the server, and starting again, or restore the entry that was deleted from the table. But either way this isn't something caused by a bug inside TNE, it's from removing from the accounts table.

dentatar commented 11 months ago

I found one player uid in accounts table without any balances in holdings table. I deleted him and could no longer reproduce the issue. Guess i messed up something without realizing ¯_(ツ)_/¯ thanks for your tips!

dentatar commented 11 months ago

I have to reopen, because it happens again. I actually wiped the entire database from last time and started from scratch without any manual intervention. Also i want to confirm is my setup actually correct? I configured TNE on one server, then stopped it and just copied entire plugins/TheNewEconomy dir to second server, changing only uuid at the end of config.yml. Thx

creatorfromhell commented 11 months ago

I have to reopen, because it happens again. I actually wiped the entire database from last time and started from scratch without any manual intervention. Also i want to confirm is my setup actually correct? I configured TNE on one server, then stopped it and just copied entire plugins/TheNewEconomy dir to second server, changing only uuid at the end of config.yml. Thx

You'll need the bungee plugin if you're looking to share balances. Everything is in a cache. As for this issue, I'm unable to reproduce so it'll be closed and marked as user error unless you have exact reproduction methods that I'm able to follow on my end.

Edit: just read about the redis, so that should be fine.

creatorfromhell commented 11 months ago

I have to reopen, because it happens again. I actually wiped the entire database from last time and started from scratch without any manual intervention. Also i want to confirm is my setup actually correct? I configured TNE on one server, then stopped it and just copied entire plugins/TheNewEconomy dir to second server, changing only uuid at the end of config.yml. Thx

TNE-BukkitCore-0.1.2.6-Pre1.zip Try using this with debug mode and post the full server log(noticed the spot for server log wasn't correctly supplied above).

Also, are you using MySQL or Maria? and what version?

dentatar commented 11 months ago

I setted up clean test network and wasn't able to reproduce this error… On my main network it happens seemingly at random and server restarts sometimes help to get rid of it. I updated TNE to version above and will leave debug enabled in case this happens again to post logs here.

I'm using MySQL 8.1 + Redis 7.2.2

dentatar commented 11 months ago

Oh i finally caught it! And can give you full logs from server start to the point where error happened. This is my second server on Paper 1.19.4 not on 1.20.1 if this is important. Error will now happen every autosave ACROSS ALL SERVERS until i restart. https://pastebin.com/nbsA77PD Also TNE reporting its version as 0.1.2.0 but i actually installed 0.1.2.6-1 you provided above on every servers.

creatorfromhell commented 11 months ago

Awesome this seems really useful. So does a player with the id ID:d5717277-9180-476c-ae1e-ae8d4c10f286 exist on one server and not the others?

dentatar commented 11 months ago

Hm. This is not a player, but rather this second server ID in config.yml. First server is caf9d750-2fb7-4037-938d-97a8ed2f1d19. Btw server account is disabled if that matters…

creatorfromhell commented 11 months ago

Hm. This is not a player, but rather this second server ID in config.yml. First server is caf9d750-2fb7-4037-938d-97a8ed2f1d19. Btw server account is disabled if that matters…

Oh, woops, I copied the wrong one I meant this UUID

1213a414-9736-3b7c-8f7a-d8a4f25b1080

dentatar commented 11 months ago

I may realized whats the problem here… Servers are in offline mode, because they are behind Velocity proxy (which is in online mode tho) but the uuids are rewritten to be offline by auth plugin? 1213a414-9736-3b7c-8f7a-d8a4f25b1080 is offline uuid of that player but in TNE his account is under 2756f293-d887-4f9d-af85-04dbdb20e2a9 which is his real uuid. Sigh… So i should enable offline in config.yml when hosting like that? I don't think this is how it should be handled, balance and all working fine for that player 🤔

creatorfromhell commented 11 months ago

I may realized whats the problem here… Servers are in offline mode, because they are behind Velocity proxy (which is in online mode tho) but the uuids are rewritten to be offline by auth plugin? 1213a414-9736-3b7c-8f7a-d8a4f25b1080 is offline uuid of that player but in TNE his account is under 2756f293-d887-4f9d-af85-04dbdb20e2a9 which is his real uuid. Sigh… So i should enable offline in config.yml when hosting like that? I don't think this is how it should be handled, balance and all working fine for that player 🤔

No should not enable offline

dentatar commented 11 months ago

But how else do i host behind proxy? This is intended configuration…

creatorfromhell commented 11 months ago

But how else do i host behind proxy? This is intended configuration…

The proxy should provide the online UUID as long as you have your proxy configured correctly and server, i.e. spigot has one for bungee where you set bungee to true in spigot.yml

creatorfromhell commented 11 months ago

Something like this

In config/paper-global.yml, set proxies.velocity.enabled to true and proxies.velocity.secret, to match the secret in your forwarding.secret file. You must also set proxies.velocity.online-mode to the online-mode setting in your velocity.toml. Once you're done editing paper-global.yml, reboot your server.

INFO If you are using Paper 1.18.2 or lower, you will find these options as settings.velocity-support.enabled, settings.velocity-support.secret and settings.velocity-support.online-mode in the paper.yml file.

Configuring modern forwarding

dentatar commented 11 months ago

Ye… I guess the issue is my auth plugin and this uuid mess. Thanks for your time reading my logs, you clarified the problem for me! I'll try to fix it and see if its actually the case. Will close this issue later if everything is ok.

creatorfromhell commented 11 months ago

Has this been resolved with the auth plugin updates or? I'm assuming it has since it has been closed. Mostly curious for future purposes.