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

manage.py is writing invalid value for the innodb_buffer_pool_size #32

Closed
headw01 opened this issue May 23, 2016 · 3 comments · Fixed by #34
Closed

manage.py is writing invalid value for the innodb_buffer_pool_size #32

headw01 opened this issue May 23, 2016 · 3 comments · Fixed by #34

Comments

@headw01
Copy link

headw01 commented May 23, 2016

The manage.py script is writing an invalid value to the config file when it starts up. According to the documentation for the innodb_buffer_pool_size, the number is in bytes. The script is writing MB (it divides the memory size KB by 1024 to get to MB).

On a 4GB memory server, it is writing 2867 which is below the minimum of 5242880. The default value for this field is 128MB (134217728).

Examining the docker log shows that the size is the minimum value

2016-05-23 15:59:05 39336 [Note] InnoDB: Initializing buffer pool, size = 5M

An alternative would be to change the my.cnf.tmpl file to specify the substitution like so to include the units:
innodb_buffer_pool_size = ${buffer}M

https://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_buffer_pool_size

from manage.py:

        # replace innodb_buffer_pool_size value from environment
        # or use a sensible default (70% of available physical memory)
        innodb_buffer_pool_size = int(get_environ('INNODB_BUFFER_POOL_SIZE', 0))
        if not innodb_buffer_pool_size:
            with open('/proc/meminfo', 'r') as memInfoFile:
                memInfo = memInfoFile.read()
                base = re.search(r'^MemTotal: *(\d+)', memInfo).group(1)
                innodb_buffer_pool_size = int((int(base) / 1024) * 0.7)

        # replace server-id with ID derived from hostname
        # ref https://dev.mysql.com/doc/refman/5.7/en/replication-configuration.html
        hostname = socket.gethostname()
        server_id = int(str(hostname)[:4], 16)

        with open('/etc/my.cnf.tmpl', 'r') as f:
            template = string.Template(f.read())
            rendered = template.substitute(buffer=innodb_buffer_pool_size,
                                           server_id=server_id,
                                           hostname=hostname)
@headw01
Copy link
Author

headw01 commented May 23, 2016

Something is odd with the issue system at the moment it appears... I created a 'duplicate' issue for this one as it was showing a 404 error when created initially.

@tgross
Copy link
Contributor

tgross commented May 23, 2016

Something is odd with the issue system at the moment it appears... I created a 'duplicate' issue for this one as it was showing a 404 error when created initially.

No worries, closed the dupe.

An alternative would be to change the my.cnf.tmpl file to specify the substitution like so to include the units:
innodb_buffer_pool_size = ${buffer}M

That seems like a good approach. Want to make a PR?

@headw01
Copy link
Author

headw01 commented May 23, 2016

Sure, here it is:

#34

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 a pull request may close this issue.

2 participants