Git Product home page Git Product logo

configuration-cache-lock's People

Contributors

ngongoll avatar paulpartington avatar paulpartington-cti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

configuration-cache-lock's Issues

Potential for unlocked config regenerations

Hey I saw this mentioned at Mage Titans and thought I'd give it a look.

I can see that while you've put locking around the Mage_Core_Model_App::_initModules there's still a chance for unlocked config cache regenration.

There is a chance that any request that retrieves configuration using Mage_Core_Model_Config:getNode() (or setNode, or init or a number of the functions in this class) could trigger an unlocked regeneration by doing the following steps:

  1. Mage_Core_Model_Config:getNode()
  2. Mage_Core_Model_Config:getSectionNode($path);
  3. Mage_Core_Model_Config:_getSectionConfig($path);
  4. Mage_Core_Model_Config:_loadSectionCache($path);

_loadSectionCache() is the killer here. Look at how it's defined:

protected function _loadSectionCache($sectionName)
{
    $cacheId = $this->getCacheId() . '_' . $sectionName;
    $xmlString = $this->_loadCache($cacheId);
    /**
     * If we can't load section cache (problems with cache storage)
     */
    if (!$xmlString) {
        $this->_useCache = false;
        $this->reinit($this->_options);
        return false;
    } else {
        $xml = simplexml_load_string($xmlString, $this->_elementClass);
        return $xml;
    }
}

If we fail to load this single node from cache for any reason, we invalidate the entire config cache and reinitialise it. This reinit functionally is fully internal to Mage_Core_Model_Cache and will not be subject to your cache locking mechanism. reinit will eventually call init which should look scarily familiar to you as something which needs proper locking applied to it.

public function init($options=array())
{
    $this->setCacheChecksum(null);
    $this->_cacheLoadedSections = array();
    $this->setOptions($options);
    $this->loadBase();
    $cacheLoad = $this->loadModulesCache();
    if ($cacheLoad) {
        return $this;
    }
    $this->loadModules();
    $this->loadDb();
    $this->saveCache();
    return $this;
}

Magento had actually made an attempt at cache locking but it's obviously not working very well. It is around the saveCache but perhaps it also needs a little extra locking in the init() function. I wonder if it would be possible to amalgamate the two rather than having two - potentially competing - cache locks.

Also just a little thing you might find interesting, during the talk you mentioned this cache locking had a little bonus feature as only the first request would trigger any available setup scripts. With a little config you can completley disable the automatic application of setup scripts which puts the control in your hands, allowing you to trigger setup scripts as a final part of your deployment using magerun.

All in all, neat stuff. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.