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

Fix wrong physical memory #780

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Conversation

vlatan
Copy link
Contributor

@vlatan vlatan commented Apr 23, 2024

Closes #779

The variable $physical_memory is correctly assigned from forcemem and converted to bytes early in sub os_setup (line 523).

$physical_memory = $opt{'forcemem'} * 1048576;

But then on line 598 it is reassigned (overwritten) from a forcemem value, if existing, without converting it to bytes.

$physical_memory=$opt{forcemem} if (defined($opt{forcemem}) and $opt{forcemem} gt 0);

This leads to a problem when converted/rounded back to KB, MB or GB in hr_bytes. Now because of the reassignment $physical_memory has the MB value, but hr_bytes treats that value as bytes.

$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);

This will lead to incorrectly determining the Physical memory. For example if a user passes --forcemem 2000, the hr_bytes will convert that to 2.0K, thinking 2000 is bytes, and the result in the console will be:

[--] Physical Memory: 2.0K

And ultimately because of this, mysqltuner will give wrong suggestions about the memory consumption:

*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***

@vlatan vlatan changed the title Remove repeated physical_memory assignment Fix wrong physical memory Apr 24, 2024
@jmrenouard jmrenouard merged commit 198e0d5 into major:master Jul 2, 2024
4 checks passed
@jmrenouard
Copy link
Collaborator

Thanks @vlatan

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.

Wrong physical memory on remote host
2 participants