Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-23296

Template Block Cache has cache key collisions

    Details

      Description

      TL;DR; Change from crc32 to md5 as used by view cache for the cache key to reduce likelihood key collisions severely.

      Cache block paths are generated using the CRC32 algorithm, in ezpublish_legacy/lib/eztemplate/classes/eztemplatecacheblock.php eZTemplateCacheBlock::cachePath. This algorightm has a high probability of collisions (see here: http://preshing.com/20110504/hash-collision-probabilities/), which can be problematic in installations with a high number of template block cache files.

      Exchanging the hashing algorithm is no solution, as it decreases the probability of collisions, but does not eliminate it. A more useful solution would be to precede the hash in the filename with the stringified cache-keys, as they have to be unique (same keys, same cache).

        Activity

        Hide
        Gandalf Sievers added a comment -

        At the moment, we have about 2 million template block cache files. The probability of a collision is ~ 1. We already saw the result of collisions on our main news frontpage, so this is urgent.

        Show
        Gandalf Sievers added a comment - At the moment, we have about 2 million template block cache files. The probability of a collision is ~ 1. We already saw the result of collisions on our main news frontpage, so this is urgent.
        Hide
        André Rømcke added a comment -

        PR added: https://github.com/ezsystems/ezpublish-legacy/pull/1069

        @Gandalf: Feel free to test it out in your dev / staging environment.

        Show
        André Rømcke added a comment - PR added: https://github.com/ezsystems/ezpublish-legacy/pull/1069 @Gandalf: Feel free to test it out in your dev / staging environment.
        Hide
        André Rømcke added a comment - - edited

        Backport safe version is coming soon as well, it is same patch as for master but with the following setting to make sure default does not change causing cache clear on backports:

        # Controls if hash for the cache file name generated by cache blocks should use
        # md5 instead of the default crc32 which is likly to collide
        # Note: Clear all template cache when changing this!
        # Deprecated: Will be removed and changed to md5 by default in 5.4
        TemplateCacheMD5Hash=disabled
        

        Show
        André Rømcke added a comment - - edited Backport safe version is coming soon as well, it is same patch as for master but with the following setting to make sure default does not change causing cache clear on backports: # Controls if hash for the cache file name generated by cache blocks should use # md5 instead of the default crc32 which is likly to collide # Note: Clear all template cache when changing this! # Deprecated: Will be removed and changed to md5 by default in 5.4 TemplateCacheMD5Hash=disabled
        Hide
        Pedro Resende (Inactive) added a comment -

        Tested and approved by Q.A.

        Show
        Pedro Resende (Inactive) added a comment - Tested and approved by Q.A.

          People

          • Assignee:
            Unassigned
            Reporter:
            Nuno Oliveira (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 4 hours
              4h