Merge lp:~patrick-hetu/charms/precise/postgresql/fix-1224668 into lp:charms/postgresql

Proposed by Patrick Hetu
Status: Merged
Merged at revision: 64
Proposed branch: lp:~patrick-hetu/charms/precise/postgresql/fix-1224668
Merge into: lp:charms/postgresql
Diff against target: 50 lines (+12/-10)
2 files modified
config.yaml (+2/-2)
hooks/hooks.py (+10/-8)
To merge this branch: bzr merge lp:~patrick-hetu/charms/precise/postgresql/fix-1224668
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+185643@code.launchpad.net

Description of the change

This is a minimal fix to make the hooks use effective_cache_size, shared_buffers if they are set.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

This looks good, Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2013-08-22 12:37:33 +0000
3+++ config.yaml 2013-09-14 15:49:26 +0000
4@@ -233,7 +233,7 @@
5 type: int
6 description: Kernel/shmmax
7 shared_buffers:
8- default: "8MB"
9+ default: ""
10 type: string
11 description: Shared buffers
12 temp_buffers:
13@@ -254,7 +254,7 @@
14 type: float
15 description: Random page cost
16 effective_cache_size:
17- default: "128MB"
18+ default: ""
19 type: string
20 description: Effective cache size
21 #------------------------------------------------------------------------
22
23=== modified file 'hooks/hooks.py'
24--- hooks/hooks.py 2013-08-22 12:37:33 +0000
25+++ hooks/hooks.py 2013-09-14 15:49:26 +0000
26@@ -343,14 +343,16 @@
27 # num_cpus is not being used ... commenting it out ... negronjl
28 #num_cpus = run("cat /proc/cpuinfo | grep processor | wc -l")
29 total_ram = run("free -m | grep Mem | awk '{print $2}'")
30- config_data["effective_cache_size"] = \
31- "%sMB" % (int(int(total_ram) * 0.75),)
32- if total_ram > 1023:
33- config_data["shared_buffers"] = \
34- "%sMB" % (int(int(total_ram) * 0.25),)
35- else:
36- config_data["shared_buffers"] = \
37- "%sMB" % (int(int(total_ram) * 0.15),)
38+ if not config_data["effective_cache_size"]:
39+ config_data["effective_cache_size"] = \
40+ "%sMB" % (int(int(total_ram) * 0.75),)
41+ if not config_data["shared_buffers"]:
42+ if total_ram > 1023:
43+ config_data["shared_buffers"] = \
44+ "%sMB" % (int(int(total_ram) * 0.25),)
45+ else:
46+ config_data["shared_buffers"] = \
47+ "%sMB" % (int(int(total_ram) * 0.15),)
48 # XXX: This is very messy - should probably be a subordinate charm
49 conf_file = open("/etc/sysctl.d/50-postgresql.conf", "w")
50 conf_file.write("kernel.sem = 250 32000 100 1024\n")

Subscribers

People subscribed via source and target branches