Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions broken (DONT USE WILL CRASH MYSQL CONNECTION) #129

Closed
benzon opened this issue May 22, 2020 · 8 comments
Closed

Transactions broken (DONT USE WILL CRASH MYSQL CONNECTION) #129

benzon opened this issue May 22, 2020 · 8 comments

Comments

@benzon
Copy link

benzon commented May 22, 2020

Hi,

Tryed out the MySQL Transaction with latest version, and it's not fixed it's utterly broken.

Testet with following code.

SaveStorageMySQL = function()
    -- Create sqls table
	local sqls = {}
	
	-- Add each player save query and params to the two tables
	for k, v in ipairs(save) do
		local query = 'UPDATE drp_storage SET type = @type, sid = @sid, data = @data WHERE type = @type and sid = @sid'
		local parameters = {
			['@type'] = v.type,
			['@sid'] = v.sid,
			['@data'] = json.encode(storage[v.type][v.sid])
		}
		table.insert(sqls, {
			query = query,
			parameters = parameters
		})
	end

	-- Execute the transaction
	MySQL.Async.transaction(sqls, cb)
end

The Save works, but if the resource is restartet a couple of times it locks up fully, and even normal MySQL connections from the fxserver wont work unless fx is restartet.

@benzon
Copy link
Author

benzon commented May 22, 2020

Not sure why transaction ends up locking up MySQL 100% but ye there is a issue with this.

@ghost
Copy link

ghost commented May 22, 2020

Cannot reproduce that locally. Doing multiple transactions works fine for me.

Can you create a minimum working example, so i have the chance of reproducing your issue?

@benzon
Copy link
Author

benzon commented May 22, 2020

Did you remember to try and restart the resource a couple of times ? 5-10 times and suddenly it locks up.

@benzon
Copy link
Author

benzon commented May 23, 2020

Only test code i got is a script im working on, would not mind sharing it with you, but dont wanna share it with the world not right now adleest.

But tryed to use transactions for saving but if i restart it a couple of times it ends in a lock up.

@benzon
Copy link
Author

benzon commented May 23, 2020

If i revert over to normal Async calls to save the date no lock up on several restarts of the resource.

@ghost ghost closed this as completed in 358753b May 23, 2020
@ghost
Copy link

ghost commented May 23, 2020

With the next version it will be fixed. You can run

npm i && npm run build with node.js installed in the source folder to get a development build.

@benzon
Copy link
Author

benzon commented May 23, 2020

Sounds good, so there was a flaw in the code ? nice that it got fixed.

@ghost
Copy link

ghost commented May 24, 2020

#129 (comment)

That comment made it so i could reproduce the issue, meaning i could see myself what was wrong, from which on it was really easy to fix.

If you have an issue, and tell me how i can trigger it myself, I can actually fix stuff; and that often really quickly if it is important broken stuff.

Sadly nobody does that when reporting an issue. I might have a hunch where stuff is wrong in some cases, but with limited time, I often do not have the time to look in detail.

e.g. the high tick rate people, it is likely their server is just overloaded with resources, sending data between resources eats up a budget. Like at some point your pc cannot be faster. Since mysql-async sends data on the next tick, it often looks like the culprit when it is not.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant