We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42252
    • 17 Posts
    Quote from: zerreissen at Dec 12, 2012, 02:28 PM
    So, it would appear that even though the newer versions of Modx is giving the ability to disable flock, it appears that the application is still using flock. I still see errors "Exclusive locks are not supported for this stream" on a site that has had flock disabled using the new variables in the latest version (./core/xpdo/xpdo.class.php: const OPT_USE_FLOCK = 'false';
    )

    On a host such as GoDaddy, you probably won't see the file corruption because of their single node environment (we use a multi node environment).

    Speaking of multi node, Modx looks to be using the process PID, which won't work reliably on our environment as the same PIDs can be re-used at the same time in our environment on the different nodes. A more reliable process might be to use the hostname/servername in conjuction with the PID.

    OpenGeek - can you offer any insight into trying this?

    Thank you
      • 36722
      • 101 Posts
      HUZZAH! Finally some real actionable information. Thanks zerrelssen, it's goot to know you're on the inside helping on this.
        Shawn Himmelberger
        Himmelberger Design
        https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Design | https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Development
        • 8307 ☆ A M B ☆
        • 77 Posts
        So this looks like something that modx will need to address!
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: zerreissen at Dec 12, 2012, 02:28 PM
          So, it would appear that even though the newer versions of Modx is giving the ability to disable flock, it appears that the application is still using flock. I still see errors "Exclusive locks are not supported for this stream" on a site that has had flock disabled using the new variables in the latest version (./core/xpdo/xpdo.class.php: const OPT_USE_FLOCK = 'false';
          )
          First, you do not change the constant to a string value of false in the xPDO class to disable flock. You must add this to the config_options array as:

          $config_options = array(
              xPDO::OPT_USE_FLOCK => false,
          );


          When you do this, xPDO uses an alternative method of writing the file that does not rely on flock being reliable. However, my understanding was that the use of LOCK_EX that is triggering this error (when this is configured properly) would fail quietly when used on file_write_contents(). This can easily be worked around by adjusting the call to remove the LOCK_EX option on that call to file_write_contents(). This was already discovered, but I'm not sure it is resolving the problem completely.

          Quote from: zerreissen at Dec 12, 2012, 02:28 PM

          On a host such as GoDaddy, you probably won't see the file corruption because of their single node environment (we use a multi node environment).

          Speaking of multi node, Modx looks to be using the process PID, which won't work reliably on our environment as the same PIDs can be re-used at the same time in our environment on the different nodes. A more reliable process might be to use the hostname/servername in conjuction with the PID.
          That is helpful and again, an easy improvement that can be made to the alternative file locking code.
            • 22303 MODX Staff
            • 10,725 Posts
            Maybe this could help. Below is the test script I used to write and compare the alternative file-locking code. Just put this in a php script in your MODX_BASE_PATH and call it using the Apache ab tool, or http_load (my preferred tool), to see how it performs with the various options available for file locking in MODX. Calling it with a higher concurrency level will reveal more lock conflicts.

            <?php
            include dirname(__FILE__) . '/config.core.php';
            include MODX_CORE_PATH . 'model/modx/modx.class.php';
            
            $config = array(
                'log_level' => modX::LOG_LEVEL_INFO,
                'log_target' => XPDO_CLI_MODE ? 'ECHO' : 'HTML',
                xPDO::OPT_USE_FLOCK => false,
                xPDO::OPT_CACHE_ATTEMPTS => 1,
                xPDO::OPT_CACHE_ATTEMPT_DELAY => 250
            );
            
            $modx = modX::getInstance('test', $config);
            $modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
            $modx->setLogLevel(modX::LOG_LEVEL_INFO);
            
            $modx->getCacheManager();
            
            $content = uniqid('contents-');
            
            $result = $modx->cacheManager->writeFile('test-lock.txt', $content);
            echo $result ? '1' : '0';
            
              • 8307 ☆ A M B ☆
              • 77 Posts
              I don't think we can call those apache tools in the rackspace environment.... unless you're talking to Chris from Rackspace?
                • 8307 ☆ A M B ☆
                • 77 Posts
                I modified this line in the xpdo.class.php

                //const OPT_USE_FLOCK = 'use_flock';
                const OPT_USE_FLOCK = 'false';

                But I am still seeing the issues.
                  • 8307 ☆ A M B ☆
                  • 77 Posts
                  Jason - what file should I add this too?


                  $config_options = array(
                  xPDO::OPT_USE_FLOCK => false,
                  );
                    • 8307 ☆ A M B ☆
                    • 77 Posts
                    sorry - ok I changed the constant added the config_option and am still seeing the issue. I waited a few minutes in case it was a propagation thing on Rackspace too. Cleared my session to release the class etc etc.
                      • 22303 MODX Staff
                      • 10,725 Posts
                      I've added a new 2.2.7-dev build with a patch to remove the LOCK_EX flag in the xPDOCacheManager::lockFile() method, as well as an attempt at multi-node support using $_SERVER['SERVER_ADDR'] if available, falling back to PHP's gethostname(). Anyone want to give it a whirl on an RS Cloud Sites account? Here they are:

                      http://modx.s3.amazonaws.com/releases/2.2.7/modx-2.2.7-dev-20121213.zip
                      http://modx.s3.amazonaws.com/releases/2.2.7/modx-2.2.7-dev-20121213-advanced.zip