Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47917

Memcached store does not guarantee get_many() key order to be returned

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.6.5, 2.7.2, 2.8
    • 2.6.6, 2.7.3
    • Unit tests
    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • 47917-28
      1. Set up two memcached servers to run - one on 11211 and one on 11212
      2. Add this to your config.php define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', '127.0.0.1:11211' . "\n" . '127.0.0.1:11212');
      3. Run unit tests

    Description

      Was doing a complete run (without unit tests skipped) of Moodle 2.8, so I defined 2 memcached instances:

      define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', '127.0.0.1:11211' . "\n" . '127.0.0.1:11212');
      

      And then I get this constant failure:

      There was 1 failure:
       
      1) cachestore_memcached_test::test_test_instance
      Failed asserting that Array (
          'many5' => 'many5'
          'many1' => 'many1'
          'many3' => 'many3'
          'many6' => false
      ) is identical to Array (
          'many1' => 'many1'
          'many3' => 'many3'
          'many5' => 'many5'
          'many6' => false
      ).
       
      /Users/stronk7/git_moodle/integration/cache/tests/fixtures/stores.php:151
      /Users/stronk7/git_moodle/integration/cache/tests/fixtures/stores.php:61
      /Users/stronk7/git_moodle/integration/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit -v cachestore_memcached_test cache/stores/memcached/tests/memcached_test.php
      

      So I tried using the Memcached::GET_PRESERVE_ORDER flag in the getMulti() call. But then ended with:

      1) cachestore_memcached_test::test_test_instance
      Failed asserting that Array (
          'many1' => 'many1'
          'many3' => 'many3'
          'many5' => 'many5'
          'many6' => null
      ) is identical to Array (
          'many1' => 'many1'
          'many3' => 'many3'
          'many5' => 'many5'
          'many6' => false
      ).
      

      (i.e. seems that using that flag returns null for non-existing elements)

      So, I'm not sure if we can change those nulls to falses safely (and rely in the flag to return key-ordered results) or, instead, we should iterate in PHP and build the results array manually.

      But we need this fixed to get a 100% pass without skipped tests. And order sounds like a good thing to get observed IMO.

      To decide and fix, ciao

      Attachments

        Issue Links

          Activity

            People

              samhemelryk Sam Hemelryk
              stronk7 Eloy Lafuente (stronk7)
              Frédéric Massart Frédéric Massart
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Nov/14