FPtje / DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
https://darkrp.miraheze.org
MIT License
463 stars 710 forks source link

MYSQL errors (when the server cannot connect to the MySQL server) #1732

Closed gamemann closed 9 years ago

gamemann commented 9 years ago

Hello, I would like to report an issue with using MYSQL in DarkRP.

L 12/29/2014 - 11:20:00: Lua Error: [ERROR] gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:240: attempt to index local 'query' (a nil value)

  1. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:240
    1. storeMoney - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:250
    2. addMoney - gamemodes/darkrp/gamemode/modules/money/sv_money.lua:13
      1. unknown - gamemodes/darkrp/entities/entities/spawned_money/init.lua:24

Yes, the MySQL server was disconnected for a short period of time, but it shouldn't be spamming errors such as these.

I'm not that good at lua coding, but I've made it so my lua scripts don't spit out any errors and reconnect to MySQL (without any lag) after MySQL comes back online. (not sure if it already does this).

We would prefer to use MySQL over Sqlite, so switching to Sqlite isn't an option at the moment.

I've also updated DarkRP a few days ago (25th I believe), but I haven't seen this fixed in the updates following.

Thank you for reading.

Thanks, Gamemann

FPtje commented 9 years ago

Please update anyway. I changed quite a bit in the MySQL backend

gamemann commented 9 years ago

Alright, I will when I get the time.

Thanks for the fast response!

Thanks, Gamemann

FPtje commented 9 years ago

Also, under what circumstances is your server disconnecting from MySQL?

gamemann commented 9 years ago

The MySQL server was timing out. The machine was up, and SSH was working but MySQL wasn't accessible (down).

Thanks, Gamemann

FPtje commented 9 years ago

Changing DarkRP to make it resistant to database failure would be very hard. Players who join are put in a limbo state and can't accept any money changes because the database doesn't work. Anything that changes in the server would have to be stored elsewhere temporarily until the database comes back. When it does come back the data needs to be synced.

This would be a big project and it will need to more and more problems. It's better in every way to have DarkRP assume the database is there and it works. This assumption works well enough.