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

Mysql Connections Count is not accurate Fixes #198 #202

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Mysql Connections Count is not accurate Fixes #198 #202

merged 1 commit into from
Nov 8, 2023

Conversation

Saifallak
Copy link
Contributor

@Saifallak Saifallak commented Nov 3, 2023

Per Discussion #198

as you can see here:

$connection instanceof MySqlConnection => (int) $connection->selectOne('show status where variable_name = "threads_connected"')->Value,

we're using show status where variable_name = "threads_connected" which shows overall server processes not my user-only this is wrong when running several apps on the same server and setting max_user_connections to like 60 per app. it should warn me when my user exceeds the limit not the overall server.

so it should be changed to SELECT COUNT(*) FROM information_schema.PROCESSLIST;

this won't be breaking change for others, as if you're the only user on the server or using root mysql, this will return same data, but if user is shared with other apps or other users (ex: Shared Hosting) it will return his processes only, so he can be notified when his app is doing something wrong.

tell me what you think and i can open PR.

If interested in this PR and wants to use it.

open composer.json and add the following:
in require

        "spatie/laravel-health": "dev-fix/mysql-count-per-user as 1.23.4"

in repositories

        {
            "type": "vcs",
            "url": "https://github.com/Saifallak/laravel-health.git"
        }

@Saifallak Saifallak changed the title mysql-count-per-user Mysql Connections Count is not accurate Fixes #198 Nov 3, 2023
@freekmurze freekmurze merged commit 8740e80 into spatie:main Nov 8, 2023
6 checks passed
@Saifallak Saifallak deleted the fix/mysql-count-per-user branch November 8, 2023 12:43
@Saifallak
Copy link
Contributor Author

Thanks @freekmurze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants