Skip to content

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

@headw01

Description

@headw01

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions