FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
138 stars 55 forks source link

December update broke return of queries #102

Closed Brandon81 closed 2 years ago

Brandon81 commented 2 years ago

Hello there,

With another guy I talked with, we got a problem on the return of data.

We managed to have this problem on a Linux x32 architecture. With a server locally (using direct gmod server creation) (so windows architecture), we can get data with the same code running.

I even tried a Database:ping(), and the server freeze.

Strange thing : Using SQL Workbench : https://steamcommunity.com/sharedfiles/filedetails/?id=1712956238 I am able to receive data. SQL Workbench shoud be using MYSQLOO module to access mysql database.

Darktooth#7927 on discord if you want interactive chat mostly available friday 10pm GMT+1, (Paris if i'm correct) and saturday 2pm-6pm but i'll try to stay connected.

If you need any clarification, i'll try my best to explain.

Kefta commented 2 years ago

Could you provide minimal reproduction code?

Brandon81 commented 2 years ago

Tried to use also : SELECT FROM dailyreward_reward SELECT FROM 'dailyreward_reward'

Don't mind all prints, all of them are almost debug

Db connexion :

pdo_co = false
pdo_pro_co = false
function connectdb()
    print(DATABASE_HOST)
    print(DATABASE_NAME)
    print(DATABASE_USERNAME)
    -- print(DATABASE_PASSWORD)
    -- print(3306)
    pdo = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, tonumber(DATABASE_PORT))
    pdo.onConnected = function() 
        print("[DB Reward] Connecté spèce de salaud")
        pdo_co = true
    end
    pdo.onConnectionFailed = function()
        print("[DB Reward] Sa marche pas la connection salaud")   
    end
    pdo:setAutoReconnect(true)
    pdo:connect()
end

Using this :

    local rqtRecomp = pdo:query( "SELECT * FROM darktooth_gmodig.dailyreward_reward;")
    print(pdo:hostInfo())
    print(pdo:serverInfo())
    print(pdo:serverVersion())
    local tab = {}
    rqtRecomp.onSuccess = function(q,data)
        print("la query : ")
        print(q)
        for k,v in pairs(data) do
            tab[k]=v
        end
        print("on a recup les recompences :")
        PrintTable(tab)
    end
    rqtRecomp.onData = function(q,data)
        print("onData : ")
        PrintTable(data)
    end

    rqtRecomp.onAborted = function(q)
        print("onAborted : ")
        print(q)
    end
    rqtRecomp.onError= function(q, err, sql)
                            print("[DB Reward] Erreur lors de la récupération des récompenses")
                            print(err)
                            tab = "err"
                        end
    rqtRecomp:start()
    print(rqtRecomp:isRunning())
    print("on attends")
    -- rqtRecomp:wait(true)
    print("on a attendu normalement")
    timer.Simple(3, function() 
        print(rqtRecomp:isRunning())
    end)
    return tab
end

was using rqtRecomp:wait(true) but server kept freezing so i removed it so i can "see" if something is happening

Nothing is called back on rqtRecomp : no onError, no onAborted, no onSuccess, no onData...

Another problem is that pdo:ping() freeze the server too.

A really minimal reproduction :

rqt= db:query("SELECT * FROM anyTable")

rqt.onSuccess = function(q,data)
   PrintTable(data)
end
FredyH commented 2 years ago

Are the connection callbacks of the database ever run (either onConnected or onConnectionFailed?). I think the database is simply not connected, or the connection even failed.

It seems that the move to the MariaDB client has broken database:ping(), which now freezes due to it not having a timeout, I will fix this in an update.

Brandon81 commented 2 years ago

callbacks from the database works and i can even see the connexion on phpmyadmin

And onConnected is called.

A little addition of the last message of the issue : Connection from the database was badly created, I recommend to create the connection after a player join.

FredyH commented 2 years ago

The issue seems to have been a firewall issue blocking the query from receiving data from the server.