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

Postgres fails to start due to too large a shared memory setting #211

Closed
tomhughes opened this issue May 3, 2015 · 4 comments
Closed

Postgres fails to start due to too large a shared memory setting #211

tomhughes opened this issue May 3, 2015 · 4 comments
Labels
Type: Bug Does not work as expected.

Comments

@tomhughes
Copy link

On a machine with 128Gb of RAM chef is configuring postgres for 32Gb of shared memory, in /var/opt/opscode/postgresql/9.2/data/postgresql.conf:

shared_buffers = 32228MB # min 128kB

but it has only configured the kernel for 16Gb of shared memory, in /etc/sysctl.d/90-postgresql.conf:

#
# opscode private chef postgresql kernel shm tweaks
#
kernel.shmmax = 17179869184
kernel.shmall = 4194304

Postgres then fails to start, and the upgrade from chef server 11 fails a a result.

This looks like it may be a return of https://tickets.opscode.com/browse/CHEF-3889?

@yinym
Copy link

yinym commented May 27, 2015

It seems that current Chef server 12 embedded private_chef cookbook did not fix this issue.

In https://github.com/chef/chef-server/blob/master/omnibus/files/private-chef-cookbooks/private-chef/attributes/default.rb#L410, the shmmax has been set to 17179869184, which is the value of 16GB in bytes.

However, in the following logic to calculate shared_buffer from line 424 - line 432:

quarter_mem = node['memory']['total'].to_i/4
postgres_max_mem = [0.85*node['private_chef']['postgresql']['shmmax'],
                    node['private_chef']['postgresql']['shmmax'] - 2*BYTES_IN_GIG].min
if(quarter_mem > postgres_max_mem)
  shared_bytes = postgres_max_mem
else
  shared_bytes = quarter_mem
end
default['private_chef']['postgresql']['shared_buffers'] = "#{shared_bytes/1024}MB"

It is actually treating this node['private_chef']['postgresql']['shmmax'] value with kB unit. In https://github.com/chef/chef-server/blob/master/omnibus/files/private-chef-cookbooks/private-chef/attributes/default.rb#L7, the value for BYTES_IN_GIG is actually in kB. node['memory']['total'] is in kB as well. So this logic will use set the shared_buffer to system memory/4 value even if this value is over the 16GB limit. (In this wrong logic, the actual limit is 16TB!).

But this can still be covered if the block in https://github.com/chef/chef-server/blob/master/omnibus/files/private-chef-cookbooks/private-chef/recipes/postgresql.rb#L68 did not put 16GB limit sysctl.

@kramvan1
Copy link

BYTES_IN_GIG = 1048576 just a bit off....maybe closer to 1073741824?

@stevendanna
Copy link
Contributor

This is being worked on here: #309

@stevendanna stevendanna added this to the accepted-minor milestone Jun 8, 2015
@stevendanna stevendanna added the bug label Jun 8, 2015
@stevendanna
Copy link
Contributor

It appears #309 has been merged, so I'm going to close this one out.

@tas50 tas50 added Type: Bug Does not work as expected. and removed bug labels Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

5 participants