Ajneb97 / ServerVariables

MIT License
5 stars 5 forks source link

MySQL is not made for server syncing. #19

Closed Kudosaki closed 1 month ago

Kudosaki commented 4 months ago

I suggest Redis as the means of server syncing for ServerVariables because this would allow people to sync between servers more accurately.

image Set Variable on Server A

image Went to Server B to check variables result is wrong.

Both are connected to the same database.

And with a brief look on the code, There seems to be nothing to update that variable when player leaves/disconnect, hence that data is most likely not possible to be viewed from Server B.

Kudosaki commented 4 months ago

Though realistically speaking for usage of variables in cases where player switches servers constantly, Redis would be the best option.

MySQL can work too, but you'll have to add a bunch of conditions when player leave & join the server aside from the autosaving.

And also to prevent the auto saving overriding each other as well.

Kudosaki commented 4 months ago

Oh, I found the variable manager area, It doesn't seems like the variables are being updated properly between servers it seems?

but restarting Server B will loads up the variable changed on A, so database definetly is working, just not updated properly when player leave & join :hmm:

Ajneb97 commented 4 months ago

The data is loaded from the database everytime they join the server.

Kudosaki commented 4 months ago

The data is loaded from the database everytime they join the server.

Doesn't seem like it's doing that right now on latest release for ServerVariables.

Server A /svar set variablename playername something

Leave Server A

Joins Server B

/svar get variablename playername Results in wrong variable

Restarting Server B /svar get variablename playername

Displays as something. So my database is connected correctly.

Ajneb97 commented 4 months ago

If you use /svar set variablename playername something, the variable is updated on the database. Could you retry the same test and check if the value on the database is updated? Make sure of that, and then, leave the server A and join server B.

Kudosaki commented 4 months ago

Sounds good, will test now

Kudosaki commented 4 months ago

image Before changing on server.

image Changed

image Still seeing no changes

UUID of player Kudosaki is 4ea416f4-7e12-3cca-83a3-f5b83276ded1

That's my UUID

Eh, the server clearly says my uuid is that but

when I change the value it's changing the value of image the d9 uuid :hurtrealbad:

image EH??

I have sent you a friend request under the name LonelyWarrior, I think we can try to diagnose this together on discord better.. than using git

Though im suspecting it's because this might be uh... offline server issue?

I'm seeing a funny behaviour though, changing the variable on both A and B updates the value on the database, but two server are displaying two different variables... I would to to stream the whole process to you lmao

Kudosaki commented 4 months ago

image Before i changed anything...

Changing on Server B image

/svar get on Server B image

image Database view when changed on server B

image /svar get on Server A

image

Setting var on Server A

image Database when changed var on Server A

image /svar get going on Server B

Kudosaki commented 4 months ago

That whole database thing ain't making lots of senses :lmao:

Ajneb97 commented 4 months ago

Why do you have the same user with 2 different UUIDs? If that's the case, then it will bug. If you changed the offline-mode of your server while having data, then this will happen. Remove the duplicated usernames.