Skip to content

[BUG] Server hangs on changelevel #138

@blobles-dev

Description

@blobles-dev

My server is suffering from a weird issue where it just hangs when changelevel occurs, no actual crash, just unresponsive. Some research has led me to this module being the cause..

This is related to: #118

Big shoutout to Warden Potato on the gmod discord for making me aware and providing this code to replicate:

local DB = mysqloo.Connect(host, username, password, database)

function DebuggingBusyQuery()
    local q = DB:query("SELECT * FROM `sometable` WHERE `somevalue` = 'SOMETHING' ORDER BY `order` DESC LIMIT " .. math.random(1, 10000))
    function q:onSuccess(rows)
    	--optional print
        --print("Result from busy query")
    end
    function q:onError() print("Errored on debug query") end
    q:start()
end

concommand.Add("robin_williams", function(ply)
	if not ply:IsSuperAdmin() then return end
	timer.Simple(2, function()
		for i = 1, 15000, 1 do
			DebuggingBusyQuery()
		end
		
		RunConsoleCommand("changelevel", "gm_flatgrass")
		print("changelevel has begun")
		
		for i = 1, 8000, 1 do
			DebuggingBusyQuery()
		end
	end)
end)

NOTE: The db should be remote, and the query should be somewhat slow, this ensures issue replication.

A simple workaround is:

hook.Add("ShutDown", "MySQLOO:KillQueriesOnShutdown", function()
	ServerLog("Shutting down a active DB connection and killing all running queries (".. DB:queueSize() ..")\n")

	DB:abortAllQueries()
	DB:disconnect(false)
end)

However, this could result in data loss, plus, you'd have to specifically add an instance for each DB, unless there's a way to grab all DB objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions