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

[Bug Fix] Fix for undefined MySQL library behavior. #2834

Merged
merged 5 commits into from
Feb 25, 2023

Conversation

KimLS
Copy link
Member

@KimLS KimLS commented Feb 6, 2023

The MYSQL structure in the MySQL C api is not copy aware. This isn't enforced because, well, C doesn't enforce anything really.
See: MySQL Structures

This changes the copy of an existing connection to instead create a second backup connection with the same data as what is being copied. This does introduce another connection into the mix which are a limited resource but given the potential seriousness of the bug in question it seems like a fair tradeoff for now.

Long term we can rewrite the dbcore class to use a underlying pointer instead of a pinned in place variable.

@KimLS
Copy link
Member Author

KimLS commented Feb 6, 2023

Gonna change some things up to get rid of the double connection, have to rewrite a bit of db core. Don't merge yet.

@Kinglykrab Kinglykrab changed the title Fix for undefined MySQL library behavior. [Bug Fix] Fix for undefined MySQL library behavior. Feb 6, 2023
Copy link
Member

@Akkadius Akkadius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaiting pointer changes

@KimLS
Copy link
Member Author

KimLS commented Feb 7, 2023

A few changes, have to test make sure they work. Also I noticed we're not sharing the mutex that protects the connection pointer so have to think up a solution for that.

(Sorry it's not all at once I'm doing this as I have time at night)

@Akkadius Akkadius force-pushed the bug-fix-undefined-behavior-mysql-copy branch from c1cf998 to 861b688 Compare February 25, 2023 00:03
@Akkadius
Copy link
Member

Synced up with KLS

We agreed that a mutex should be shared across the database instances because they share the same underlying connection. This protects from concurrency / thread-safety issues.

Reproduced Problem

image

Fixed, Running for several minutes

2023-02-24_17-23-39.mp4

@Akkadius
Copy link
Member

Tested booting up all servers, logging in game, everything works as expected

@Akkadius Akkadius merged commit de2dfc1 into master Feb 25, 2023
@Akkadius Akkadius deleted the bug-fix-undefined-behavior-mysql-copy branch February 25, 2023 02:14
@Akkadius Akkadius mentioned this pull request Feb 25, 2023
catapultam-habeo pushed a commit to catapultam-habeo/pyrelight-server that referenced this pull request Mar 27, 2023
* MYSQL objects cannot be copied in a well defined way, this removes the copy and replaces it with another connection

* Change to share underlying pointers.

* Push up mutex changes

* Post rebase

* Formatting

---------

Co-authored-by: KimLS <KimLS@peqtgc.com>
Co-authored-by: Akkadius <akkadius1@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants