fivem-mysql-async icon indicating copy to clipboard operation
fivem-mysql-async copied to clipboard

mysql-async high tick

Open MohamedAmrMahdy opened this issue 5 years ago • 32 comments

image

running mysql-async 3.2.0

MohamedAmrMahdy avatar Aug 20 '19 16:08 MohamedAmrMahdy

Having the same problem, also running gcphone, I saw in the server logs that it causing high sql ms. Tell me if you got anything

NoyWasTaken avatar Aug 26 '19 19:08 NoyWasTaken

Same problem

ArmoredSoldiers avatar Aug 26 '19 19:08 ArmoredSoldiers

Are you running OneSync 64/128 slots ? @ArmoredSoldiers @MohamedAmrMahdy

NoyWasTaken avatar Aug 27 '19 13:08 NoyWasTaken

Are you running OneSync 64/128 slots ? @ArmoredSoldiers @MohamedAmrMahdy

yes this issue happens when players get over 45 players online

MohamedAmrMahdy avatar Aug 27 '19 13:08 MohamedAmrMahdy

Me too [But only when 50+], have you found any solution or something to help it ?

NoyWasTaken avatar Aug 27 '19 13:08 NoyWasTaken

Have you tried to disable the gcphone ? @MohamedAmrMahdy

NoyWasTaken avatar Aug 27 '19 13:08 NoyWasTaken

Have you tried to disable the gcphone ? @MohamedAmrMahdy

no but i think it is not the main reason because others recourse queries get same lag

MohamedAmrMahdy avatar Aug 27 '19 13:08 MohamedAmrMahdy

I debugged the mysql, I saw that the gcphone has slow query [high ms], I've checked myself and with some of my programmers [in my server] and we saw that the phone itself built all on mysql [always query the sql and not saving data on the server/client script]

NoyWasTaken avatar Aug 27 '19 13:08 NoyWasTaken

I'm gonna make some tests to see if it does the gcphone who is causing the problem, I'll let you know. @MohamedAmrMahdy

NoyWasTaken avatar Aug 27 '19 13:08 NoyWasTaken

I've noticed to this thing in my console [on server startup]:

[32m[mysql-async][0m Database server connection established.

Authenticating with Nucleus...

server thread hitch warning: timer interval of 3040 milliseconds

NoyWasTaken avatar Aug 27 '19 16:08 NoyWasTaken

Btw: I've tried to disable the gcphone and there's still high mysql tick that is causing a delay.

NoyWasTaken avatar Aug 28 '19 13:08 NoyWasTaken

Samuray, yes, i running 75 slot with 256 player loops, and high tick up to 40-45 player up... i using OneSync plus, and use gcphone.

ArmoredSoldiers avatar Aug 29 '19 05:08 ArmoredSoldiers

Currently I'm working on finding the problem in my server. I've updated some resources and removed ones I don't need. I'll update if there's any change.

NoyWasTaken avatar Aug 30 '19 06:08 NoyWasTaken

Same here. Tried everything and disabling resources.

ghost avatar Aug 30 '19 12:08 ghost

Still no solution?

SaadGustavo avatar Nov 17 '19 21:11 SaadGustavo

image

running mysql-async 3.2.0

Hello, I want to know what is this analyzing tool?

LittleTin avatar Dec 09 '19 02:12 LittleTin

Still problem :) Nothing fixed yet

Tinky124 avatar Jan 08 '20 12:01 Tinky124

Recurring issue for us from time to time aswell, not exactly sure.

CruelAlpha avatar Jan 13 '20 10:01 CruelAlpha

Just a small question but... wouldn't changing your for loops to use the GetActivePlayers() native be much better than looping 1-256?

    for _, player in ipairs(GetActivePlayers()) do
        local ped = GetPlayerPed(player)
        -- do stuff
    end

Local9 avatar Jan 22 '20 17:01 Local9

Just a small question but... wouldn't changing your for loops to use the GetActivePlayers() native be much better than looping 1-256?

    for _, player in ipairs(GetActivePlayers()) do
        local ped = GetPlayerPed(player)
        -- do stuff
    end

Are you refering to other plugins or the mysql plugin?

CruelAlpha avatar Jan 23 '20 03:01 CruelAlpha

Has anyone tried messing around with mysql variables?

CruelAlpha avatar Jan 23 '20 03:01 CruelAlpha

Just a small question but... wouldn't changing your for loops to use the GetActivePlayers() native be much better than looping 1-256?

    for _, player in ipairs(GetActivePlayers()) do
        local ped = GetPlayerPed(player)
        -- do stuff
    end

Are you refering to other plugins or the mysql plugin?

Anything that maybe using it, is there a case that a script maybe doing something unintended which is looping up to 256 instead of the number of players connected which could cause a high tick rate. Its just a general question as I'm looking to step back tom GHMatti's C# MySQL resource that I'm using (because I like things being referenced in my C# Projects using ADO.NET as exports raise concerns for me) and use something that is more up to date like this resource as it looks to be widely used.

Local9 avatar Jan 23 '20 19:01 Local9

After more research, some of the lag can be fended off by improving the MySQL variables, but at around ~64 people the DB queries usually has over 1000ms sometimes when there is too much it racks up to 100k+ ms (until all queries are caught up). Most of our issues during lower pop (~50) was fixed by experimenting with variables.

All our tables are properly indexed as per needed I wonder if GHMatti can offer a solution or provide tips to look at to investigate it

CruelAlpha avatar May 15 '20 07:05 CruelAlpha

@CruelAlpha how many queries per second are you running, which ones are slow?

ghost avatar May 15 '20 10:05 ghost

where im putting this code? for _, player in ipairs(GetActivePlayers()) do local ped = GetPlayerPed(player) -- do stuff end

and how i change the loop to 256? thnx!!!

ProCcEeD avatar Aug 11 '20 17:08 ProCcEeD

Hi, its because you have an server loop like this:

for i=1, #players, 1 do
     -- MySQL.Async - Stuff
end

My solution to remove the high hitch time was this:

for i=1, #players, 1 do
     doMySQLStuff(players[i])
end

function doMySQLStuff(player)
    -- your MySQL.Async function stuff here
    Citizen.Wait(50)
 end

Info: When you put the Wait inside an for loop the server send an error

Try it and pease send feetback ^^ I hope it works on your servers to!!!

Antontonov avatar Dec 25 '20 11:12 Antontonov

@Antontonov , you mean something like this ?

Before : `

MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE owner = @owner AND plate = @plate', {
	['@owner'] = identifier,
	['@plate'] = plate
}, function(result)
	if result[1] then
		cb(result[1].owner == identifier)
	else
		cb(false)
	end
end)

end)`

After : `

MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE owner = @owner AND plate = @plate', {
	['@owner'] = identifier,
	['@plate'] = plate
}, function(result)
	if result[1] then
		cb(result[1].owner == identifier)
	else
		cb(false)
		-- test
		Citizen.Wait(50)
	end
end)

end)`

martink1337 avatar Jan 08 '21 00:01 martink1337

Hi, First Citizien.Wait(msec) than cb() But for only one request you dont need any wait ... i ll do that for my mysql functions inside "for"-Loops It works fine for me and i haven t any big fat hitch warnings anymore.

Edit: And in your function the poor Citizen have to wait 50 msec longer to store/get his veh. or other stuff ^^

Antontonov avatar Jan 08 '21 03:01 Antontonov

@Antontonov Interesting. I'll try to find out + I make the same thing but in client-side, which also works nice. The idea is simple. When someone uses an function from Ui menu or anywhere, he will have like 2-3 seconds cooldown, so the function will be triggered after that amount of time (the server-side code). This also works good, what you think about it ?

martink1337 avatar Jan 08 '21 12:01 martink1337

@Antontonov thanks for sharing this, looks interesting! Do you mind explaining, in what way the wait call decreases the hitch time?

CYXNNN avatar Jan 28 '21 13:01 CYXNNN