← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/memcached-item-size into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/memcached-item-size into lp:launchpad.

Commit message:
Pass a suitable item size to memcached so that MemcachedLayer works with memcached >= 1.4.29.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/memcached-item-size/+merge/364981
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/memcached-item-size into lp:launchpad.
=== modified file 'lib/lp/testing/layers.py'
--- lib/lp/testing/layers.py	2018-05-21 20:30:16 +0000
+++ lib/lp/testing/layers.py	2019-03-22 19:17:09 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Layers used by Launchpad tests.
@@ -599,9 +599,18 @@
         if MemcachedLayer.client.set(test_key, "live"):
             return
 
+        # memcached >= 1.4.29 requires the item size to be at most a quarter
+        # of the memory size; 1.5.4 lifts this restriction to at most half
+        # the memory size, but we take the more conservative value.  We cap
+        # the item size at a megabyte.  Note that the argument to -m is in
+        # megabytes.
+        item_size = min(
+            config.memcached.memory_size * 1024 * 1024 / 4,
+            1024 * 1024)
         cmd = [
             'memcached',
             '-m', str(config.memcached.memory_size),
+            '-I', str(item_size),
             '-l', str(config.memcached.address),
             '-p', str(config.memcached.port),
             '-U', str(config.memcached.port),


Follow ups