Merge lp:~marcoceppi/charms/precise/mysql/32bit-fix into lp:charms/mysql

Proposed by Marco Ceppi
Status: Merged
Merged at revision: 88
Proposed branch: lp:~marcoceppi/charms/precise/mysql/32bit-fix
Merge into: lp:charms/mysql
Diff against target: 26 lines (+9/-0)
1 file modified
hooks/config-changed (+9/-0)
To merge this branch: bzr merge lp:~marcoceppi/charms/precise/mysql/32bit-fix
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+132979@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Note that I added a check for OverflowError upon merging, because you can't compare an int to a long without raising that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/config-changed'
2--- hooks/config-changed 2012-09-13 22:49:49 +0000
3+++ hooks/config-changed 2012-11-05 21:41:18 +0000
4@@ -14,6 +14,11 @@
5 # Going for the biggest page size to avoid wasted bytes. InnoDB page size is
6 # 16MB
7 PAGE_SIZE = 16*1024*1024
8+32BIT_SYSTEM = sys.maxsize < 2**32
9+32BIT_MEM_LIMIT = human_to_bytes('4G')
10+
11+if 32BIT_SYSTEM:
12+ check_call(['juju-log','-l','INFO','32bit system restrictions in play'])
13
14 configs=json.loads(check_output(['config-get','--format=json']))
15
16@@ -37,6 +42,10 @@
17 return int(human[:-1]) * factors[modifier]
18 if modifier == '%':
19 total_ram = human_to_bytes(get_memtotal())
20+
21+ if 32BIT_SYSTEM and total_ram > 32BIT_MEM_LIMIT:
22+ total_ram = 32BIT_MEM_LIMIT
23+
24 factor = int(human[:-1]) * 0.01
25 pctram = total_ram * factor
26 return int(pctram - (pctram % PAGE_SIZE))

Subscribers

People subscribed via source and target branches

to all changes: