FPtje / DarkRP

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

Error in entityvars causing server corruption? #2459

Closed MStruntze closed 8 years ago

MStruntze commented 8 years ago

Description of the bug

The last two days, I've experienced some weird stuff. After this lua error:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:47: Tried to use a NULL entity!
  1. Send - [C]:-1
   2. setDarkRPVar - gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:47
    3. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:414
     4. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
      5. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:297
       6. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
        7. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278
         8. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
          9. offlinePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:258
           10. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:303
            11. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
             12. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:297
              13. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
               14. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278
                15. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
                 16. offlinePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:258

Which caused a single player to be "unassigned", the server started to use a file called sv-journal instead of sv.db for data storage. Meaning all data was lost from the main storage. This error caused severe issues to a lot of other stuff, though without any errors.

After this error, this was also present:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:713: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:713

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:241: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:241

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:234

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:241: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:241

These errors occured only after the other error, which was completely random after like 6 hours with players. I tried reverting darkrp a few days from yesterday to today, but like I said, it happened again.

How to make the bug happen

Unknown?

Lua errors

Posted in desc

Why the developer of DarkRP is responsible for this issue

The stack trace leads nowhere else.

FPtje commented 8 years ago

At the point of the first error, the database was already fucked. I can fix that error, but I cannot fix your database, or even prevent it from going poo poo.

MStruntze commented 8 years ago

So there's something wrong in the database clearly. I know this isn't really the place to ask such questions, but would there be anything I could do about this? I have daily backups I can recover from and find a possible anomaly. It just seems weird to happen all of a sudden.

FPtje commented 8 years ago

It is weird, but I have no idea what could have caused it. Besides of course manually fucking with the sv.db file, which I just did to reproduce your problems.

MStruntze commented 8 years ago

I use mysql for all the stuff I've made and haven't edited the file manually. Would I be able to migrate the data to mysql to locate the issue? It just happened again, so I'll have to restart with the version you just committed.

MStruntze commented 8 years ago

Will this be logged anywhere?

MStruntze commented 8 years ago

I just received the error again. It seems to be a specific player only. The last few days it's been him all the time.

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:54: Tried to use a NULL entity!
  1. Send - [C]:-1
   2. setDarkRPVar - gamemodes/darkrp/gamemode/modules/base/sv_entityvars.lua:54
    3. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:414
     4. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
      5. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:297
       6. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
        7. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278
         8. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
          9. offlinePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:258
           10. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:303
            11. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
             12. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:297
              13. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
               14. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278
                15. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:302
                 16. offlinePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:258

[ERROR] gamemodes/darkrp/gamemode/libraries/fn.lua:252: attempt to index local 'xs' (a nil value)
  1. isMayor - gamemodes/darkrp/gamemode/libraries/fn.lua:252
   2. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:849

[ERROR] A runtime error has occurred in "gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua" on line 384.
The best help I can give you is this:

There is a player with an invalid team!

The player's name is mads, their team number is "1001", which has the name "Unassigned"

Hints:
    - It is the server owner's responsibility to figure out why that player has no valid team.
    - This error is very likely to be caused by an earlier error. If you don't see any errors in your own console, look at the server console.

The responsibility for the error above lies with (the authors of) one (or more) of these files:
    1. gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua on line 384
    2. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 373
    3. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 414
    4. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 304
    5. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 299
    6. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 243
    7. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 278
    8. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 304
    9. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 258
    10. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 303
    11. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 304
    12. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 299
    13. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 243
    14. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 278
    15. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 304
    16. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 258
    17. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 303
    18. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 304
    19. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 299
    20. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 243
    21. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 278
    22. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 304
    23. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 258
    24. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 303
    25. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 304
    26. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 299
    27. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 243
    28. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 278
    29. gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua on line 304
    30. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 258
    31. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 303
    32. gamemodes/darkrp/gamemode/modules/base/sv_data.lua on line 390
    33. gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua on line 587
------- End of Simplerr error -------

  1. error - [C]:-1
   2. error - gamemodes/darkrp/gamemode/libraries/simplerr.lua:530
    3. getJobTable - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:384
     4. retrieveSalary - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:373
      5. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:414
       6. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
        7. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:299
         8. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
          9. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278
           10. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:304
            11. offlinePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:258
             12. retrievePlayerData - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:303
              13. errorCallback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:304
               14. query - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:299
                15. queueQuery - gamemodes/darkrp/gamemode/libraries/mysqlite/mysqlite.lua:243
                 16. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:278

[ERROR] A runtime error has occurred in "gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua" on line 384.
The best help I can give you is this:

There is a player with an invalid team!

The player's name is mads, their team number is "1001", which has the name "Unassigned"

Hints:
    - It is the server owner's responsibility to figure out why that player has no valid team.
    - This error is very likely to be caused by an earlier error. If you don't see any errors in your own console, look at the server console.

The responsibility for the error above lies with (the authors of) one (or more) of these files:
    1. gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua on line 384
    2. gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua on line 711
------- End of Simplerr error -------

  1. error - [C]:-1
   2. error - gamemodes/darkrp/gamemode/libraries/simplerr.lua:530
    3. getJobTable - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:384
     4. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:711

[ERROR] A runtime error has occurred in "gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua" on line 384.
The best help I can give you is this:

There is a player with an invalid team!

The player's name is mads, their team number is "1001", which has the name "Unassigned"

Hints:
    - It is the server owner's responsibility to figure out why that player has no valid team.
    - This error is very likely to be caused by an earlier error. If you don't see any errors in your own console, look at the server console.

The responsibility for the error above lies with (the authors of) one (or more) of these files:
    1. gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua on line 384
    2. gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua on line 240
------- End of Simplerr error -------
FPtje commented 8 years ago

You've explicitly said that your server is using sv.db for storage. Now you're saying that you're using MySQL. Look for earlier errors.

MStruntze commented 8 years ago

DarkRP uses sv.db - everything else uses mysql. No prior errors in the error log. Could it be the name causing a conflict? His steam name is "mads" which is a pretty common name. With the recent changes to player data lookup? (not to blame anyone). Could it cause an issue if there's a duplicate?

FPtje commented 8 years ago

You already know that your sv.db is corrupt. Replace it.

FPtje commented 8 years ago

Also, duplicate players would give a very distinct error message in the server console. I'm not seeing it.

MStruntze commented 8 years ago

Starting over isn't really an option. This is clearly a duplicate, right? https://gyazo.com/bb98bba454e139f5ae47c375fd03bf55

I can't really get the previous errors from console besides the one in the srcds generated lua_errors_server.txt. Which includes this in total: http://pastebin.com/zRsJTyLL

FPtje commented 8 years ago

It's not clearly a duplicate. One has an invisible space after it.

FPtje commented 8 years ago

Actually, the database should throw an error before a duplicate name is put in there. That's the error I'm talking about. If you think you see two duplicate RP names in the database, you're not seeing it right.

MStruntze commented 8 years ago

Yea I see. One was 7 chars yet no visible spaces.

Bo98 commented 8 years ago

I'm wondering why you are still getting invalid team errors after you said you updated because that should no longer be outputted on DB error,

FPtje commented 8 years ago

Invalid team errors should and did get thrown in my tests. It's a conscious decision because I'd rather have those thrown than this one:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:713: attempt to index local 'jobTable' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:713

At least the invalid team errors give some vague idea of what's going on and it tells you to look for earlier errors.

MStruntze commented 8 years ago

I ended up with storing all player wallets in a mysql table and then giving it to them when they joined again in the new database. Thank you for your assistance.

Bo98 commented 8 years ago

@FPtje Yeah, I just read the commit wrong, thought it was a not DarkRPDataRetrievalFailed.

Anyway, isn't the error is preventing the SQL error from throwing though?

Error callback -> Try to retrieve salary -> Try to get player job table -> Invalid team error that halts execution (SQL error not thrown)

Bo98 commented 8 years ago

(What I said is probably SQLite specific due to how callbacks are immediate and thus means the team will never be set in time)

MStruntze commented 8 years ago

I just had the exact same issue with a database only 4 days old. Clearly there's something wrong somewhere. Unfortunately, I didn't have the update from 21 hours ago, but I've updated and will return with the hopefully more useful error.