We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43374
    • 39 Posts
    I moved my MODX Revolution 2.2.8-pl (traditional) site to a new webserver. After the move I have a strange behavior: once a day or every few hours in the DB the table "..._site_templates" gets corrupted.

    If I restore the table with a backup the site works again.

    This is the working table:


    This is the corrupted table:


    Has anyone any idea how I could troubleshoot this?

    Note: I updated now to 2.14 and it still happens.
    [ed. note: sh0ck23 last edited this post 9 years, 10 months ago.]
    • I have a few questions.

      1. Are you doing development in the manager, so that the cache is getting cleared frequently?

      2. Have you checked and repaired the table after restoring it?

      3. How are you restoring it? Are you using DROP TABLE/CREATE TABLE?

      Personally, I would be inclined to export the entire database as data-only, no structure, then drop the whole database, create a new database with a new username and password, import the data-only backup, and edit the config.inc.php file to update the username and password.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • Ok, that wasn't too clear. Here's what I would do.

        1. Export the entire database, data-only, no structure.
        2. Make a new installation of MODX - this could be done in a subdirectory of your existing site; it will never actually be run, and that would make it very easy to switch to using the new database.
        3. Empty all of the new database's tables (keep the structure, just truncate the tables)
        4. Import your data-only dump from your site.
        5. Edit your site's config.inc.php to use the new database. Don't forget the $database_dsn line!
        6. Delete the temporary MODX installation. Keep the old database until you're sure the new one is working - at worst you can just edit the config.inc.php file again to go back to using the old database.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          Also, do you have any template-related plugins running? If so, which one(s)?
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 43374
            • 39 Posts
            I am still investigating which is a little difficult since the issue is only occuring unfrequently approx. once a day.

            1. Are you doing development in the manager, so that the cache is getting cleared frequently?
            -> at the moment I am not developing at all on this site jsut fixing this issue but generally yes I am develoving in the manager on top I also cleared cache manually by deleting the whole cache folder content

            2. Have you checked and repaired the table after restoring it?
            3. How are you restoring it? Are you using DROP TABLE/CREATE TABLE?
            -->Yes I droped the table and restored it with "mysqldumper"

            Also, do you have any template-related plugins running? If so, which one(s)?
            --> not 100% sure which plugin this could be since most of them are more ore less template-related. I am running folowing packages:


            • Babel
            • getResourceField
            • getResources
            • UltimateParent
            • Wayfinder

            From my understanding if its related to any plugin it would be a plugin that is generally able to run "UPDATE" on SQL tables so either Babel or Wayfinder the other 3 should be only pulling data not writing any if I am correct. As a temporary hotfix I removed the "UPDATE" privilige from the modx SQL user wich seems to avoid the table corruption.

            Regarding merging the content into a clean MODX installation that is definetly a step I will do if I can not identify the core of the issue for now I will still digg a little deeper into it to find out whats wrong so I can avoid it in the future.

            • Have you tried to run a repair on the table? such as phpMyAdmin's Operations -> Table Maintenance -> Check table, Repair table and Optimize table?

              None of those snippets should be doing any updating or writing to the site_templates table. Plugins are not snippets, anyway. Babel does have a plugin, but again, it shouldn't be doing any writing to the site_templates table.

              The templates are always taken from cache unless the cache has been cleared, then the first time a template is referred to it's taken from the database and put in the cache again. But unless you're saving a template, there are no snippets or plugins or other functions that should be updating or writing to that table.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 40045
                • 534 Posts
                maybe you can put something like that into core/model/modx/processors/element/template/update.class.php

                $this->modx->log(modX::LOG_LEVEL_ERROR, '[modTemplateUpdateProcessor] Running with properties: ' . print_r($this->getProperties(), 1));
                


                let it there for a few days and check the error log for entries...
                  • 3749
                  • 24,544 Posts
                  I would recommend updating to 2.2.14 at a time when you know things are OK. Some of the early 2.2.x versions has problems with cache corruption. I thought it was fixed by 2.2.6, but maybe not.

                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                  • Could you provide us with more information about your hosting environment?
                      Patrick | Server Wrangler
                      About Me: Website | TweetsMODX Hosting