Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Major mixed tables bug that is killing my game?

Asked by
natsaa 5
6 years ago

Okay, so I'm getting this error: https://i.gyazo.com/a6d74a71e3437f2aead11dbbecb07aef.png

I've spent the last 3-4 days trying to find the source of this while my game slowly has gone from 300+ concurrent to 50 concurrent due to this bug breaking everything in the game. The table in question is the player data, so its not something I can easily eye ball to see whats causing this. This error also seems to come out of nowhere, and will happen to everyone at any point during a server life. Sometimes after 5 minutes, sometimes right off the bat, sometimes after 2 hours, its entirely random. I've tried to do some debugging and reverse engineering to narrow it down quite a bit, and I've chopped it up to happen anytime the server asks for player data. But this is what I'm using for my player data module:

function metaData:get(player)
    if player and player.UserId then
        local result, errorm =  pcall(function()
            if data[tostring(player.UserId)] == nil then
                metaData:addUser(player)
            end

            local testingTable = {}
            testingTable[tostring(player.UserId)] = data[tostring(player.UserId)]
            local bux = testingTable[tostring(player.UserId)].Stats.Bux     
        end)
        if result then
            return data[tostring(player.UserId)];
        else
            warn("get error")
            warn(errorm)
        end
    end
end

function metaData:update(player, pdata)
    if player and player.UserId and pdata then
    local result, errorm = pcall(function()
            local testingTable = {}
            testingTable[tostring(player.UserId)] = pdata
            local bux = testingTable[tostring(player.UserId)].Stats.Bux
    end)
    if result then
        data[tostring(player.UserId)] = pdata
    else
        warn("Player Data Module Error")
        warn(errorm)
    end
    end
end

As you can see, both instances use a pcall on a table and attempt to reference the table (the same thing my client controller and game controller are doing), so if the table is bugged it should throw an error, BUT IT NEVER DOES. It ALWAYS goes through, and further more, heres some other fishy stuff happening:

So this is what the client is doing:

function updatePlayer(pData)
    local success, message = pcall( function() pData = updateClientRemote:InvokeServer() end)   
    if success then
        -- irrelevant some what sensitive code stuff 
    else
        warn("CLIENT: Update player issue")
        print(message)
    end
end

And it throws the error I posted above, along with that warning I posted (the screenshot was before I implemented that warning)

But heres what my server script looks like thats catching the remote:

function updateClientRemote.OnServerInvoke(player)
    local result, errorm = pcall(function()
    pData = playerDataModule:get(player)
        if pData then
            -- irrelevant sensitive data
        end
    end)

    if result then
        return pData
    else
        warn("problem with updateplayer with")
        warn(player)
        warn(errorm)
        warn("---")
    end
end

And it returns player data? No issues what so ever.

At this point, I'm legit stumbled on whats going on, and am legit getting stressed out to the max at the rate my game is dying and my inability to even have hope to resolve the problem. I've tried everything I can think of, but I'm honestly stuck. I wish there was a way to see WHAT part of the table specifically is causing the error, then that would probably help me a TON, but I don't even know since the player data module shouldn't even let it pass with an error. Anyone who can offer any sort of support, that would be insanely appreciated.

0
Try getting rid of the redundant pcall functions on the server script listening to the remote function invoke and the pcall in the local script. Pcall should only be used on functions that have a possibility of failing such as direct accesses to data stores. Because you have so many functions wrapped in pcall, you're not allowing errors happening on the lower level to propagate up and show themsel RayCurse 1518 — 6y

Answer this question