My system
- Series of Ubuntu 14.04.5 (x86_64) Servers, kept updated
- My application required I increase stack depth for postgres
- I created a file in /etc/security/limits.d/myapplication.conf
- The myapplication.conf file has the line:
* - stack 131072
- Note that 131072KB == 128MB
- Upon making this myapplication.conf file, my
ulimit -s
returns:131072
- I then edited my /etc/postgresql/9.3/main/postgresql.conf file and appended the line:
max_stack_depth = 126MB
My problem
During boot, the following message appears:
* The PostgreSQL server failed to start. Please check the log output:
2018-01-24 09:27:53 MST LOG: invalid value for parameter "max_stack_depth": 129024
2018-01-24 09:27:53 MST DETAIL: "max_stack_depth" must not exceed 7680kB.
2018-01-24 09:27:53 MST HINT: Increase the platform's stack depth limit via "ulimit -s" or local equivalent.
2018-01-24 09:27:53 MST FATAL: configuration file "/etc/postgresql/9.3/main/postgresql.conf" contains errors
* Starting Mount network filesystems [ OK ]
* Starting PostgreSQL 9.3 database server * Stopping Mount networ[ OK ]systems
[fail]
This in turn causes my application service to then fail, as I depend on my databases. After boot, if I start the postgres service, it's fine:
dev@wipn:~$ sudo service postgresql start
* Starting PostgreSQL 9.3 database server [ OK ]
dev@wipn:~$
My guess is that the effects of /etc/security/limits.d/myapplication.conf are only applied at a stage during boot that's after when my system tries to start postgres. So, perhaps an obvious solution is to just change when I start postgres, that's fine and I can handle that.
My Question
What's a way to change the kernel's stack depth, such that I need only make minimal alterations to my servers?
I want something as clean as possible. I want it to withstand upgrades and preferably be applicable to other distros. I manage my stuff through Ansible plays, so I'd rather write one clean play for this.
It may simply be the case that changing start order of my services is the best resolution. Anyone out there know of other suitable options?
Things I've tried
Here's a list of some of the things I've tried, without success.
In /etc/security/limits.d/myapplication.conf:
postgres - stack 131072
* - stack 131072 root - stack 131072