putyourlightson / craft-blitz

Intelligent static page caching for creating lightning-fast sites with Craft CMS.
https://putyourlightson.com/plugins/blitz
Other
147 stars 35 forks source link

SEOmatic possibly triggering an infinite loop on Cloudfront invalidation requests #676

Closed jan-dh closed 2 weeks ago

jan-dh commented 2 weeks ago

Bug Report

Yesterday we had a situation where the following happend:

  1. We notice an event from SEOmatic that caused an error
  2. Next thing we see is an infinite loop starting from Blitz to invalidate caches which ramped up to 170.000k Blitz tasks in queue
  3. When further inspecting, it seems all the blitz cache entries in the DB gotten an expiry date (of the exact moment the SEOmatic error happend)
  4. Flushing the DB & clearing the queue managed to solve this

The SEOmatic event which was flagged already with Andrew

[web.ERROR] [nystudio107\\seomatic\\services\\MetaBundles::updateMetaBundle] Meta bundle failed validation: Array (     [typeId] => Array         (             [0] => Type Id must be no less than 1.         )  )  type: channel id: 12 from siteId: 8 

The report shows not a lot of items being tracked since the DB was flushed

Diagnostics Report

Application Info

Installed Plugins

Loaded Modules

Blitz Plugin Settings

{
    "debug": true,
    "hintsEnabled": true,
    "cachingEnabled": true,
    "refreshCacheEnabled": true,
    "refreshMode": 2,
    "includedUriPatterns": [
        {
            "siteId": "",
            "uriPattern": ".*"
        }
    ],
    "cacheStorageType": "putyourlightson\\blitz\\drivers\\storage\\YiiCacheStorage",
    "cacheStorageSettings": [],
    "cacheStorageTypes": [],
    "cacheGeneratorType": "putyourlightson\\blitz\\drivers\\generators\\HttpGenerator",
    "cacheGeneratorSettings": {
        "concurrency": "3"
    },
    "cacheGeneratorTypes": [],
    "customSiteUris": [],
    "cachePurgerType": "putyourlightson\\blitzcloudfront\\CloudFrontPurger",
    "cachePurgerSettings": {
        "condenseUrls": false
    },
    "cachePurgerTypes": [],
    "deployerType": "putyourlightson\\blitz\\drivers\\deployers\\DummyDeployer",
    "deployerSettings": [],
    "deployerTypes": [],
    "ssiEnabled": true,
    "ssiTagFormat": "[an error occurred while processing the directive]",
    "detectSsiEnabled": true,
    "esiEnabled": false,
    "queryStringCaching": 2,
    "includedQueryStringParams": [
        {
            "siteId": "",
            "queryStringParam": ".*"
        }
    ],
    "excludedQueryStringParams": [
        {
            "siteId": "",
            "queryStringParam": "gclid"
        },
        {
            "siteId": "",
            "queryStringParam": "fbclid"
        }
    ],
    "apiKey": "",
    "generatePagesWithQueryStringParams": true,
    "purgeAssetImagesWhenChanged": true,
    "refreshCacheAutomaticallyForGlobals": false,
    "refreshCacheWhenElementMovedInStructure": true,
    "refreshCacheWhenElementSavedUnchanged": false,
    "refreshCacheWhenElementSavedNotLive": false,
    "cacheNonHtmlResponses": false,
    "trackElements": true,
    "trackElementQueries": true,
    "excludedTrackedElementQueryParams": [],
    "cacheElements": true,
    "cacheElementQueries": true,
    "cacheDuration": null,
    "nonCacheableElementTypes": [],
    "sourceIdAttributes": [],
    "liveStatuses": [],
    "integrations": [
        "putyourlightson\\blitz\\drivers\\integrations\\FeedMeIntegration",
        "putyourlightson\\blitz\\drivers\\integrations\\SeomaticIntegration"
    ],
    "defaultCacheControlHeader": "no-cache, no-store, must-revalidate",
    "cacheControlHeader": "public, s-maxage=2592000, max-age=2592000",
    "cacheControlHeaderExpired": "public, s-maxage=5, max-age=0",
    "sendPoweredByHeader": true,
    "outputComments": true,
    "refreshCacheJobPriority": 10,
    "driverJobBatchSize": 100,
    "driverJobPriority": 100,
    "queueJobTtr": 3600,
    "maxRetryAttempts": 2,
    "maxUriLength": 255,
    "mutexTimeout": 30,
    "commands": [],
    "injectScriptEvent": "DOMContentLoaded",
    "injectScriptPosition": 3
}

Recommendations

Site Tracking [#1]

Site Tracking [#2]

Site Tracking [#3]

Site Tracking [#4]

Site Tracking [#5]

Site Tracking [#6]

Site Tracking [#7]

Site Tracking [#8]

bencroker commented 2 weeks ago

Do you have a link to where this has been reported to SEOmatic so I can follow along and see if any improvements can be made in the Blitz integration?

jan-dh commented 2 weeks ago

This is the commit (for V5 but it's being implemented for all versions); not released atm: https://github.com/nystudio107/craft-seomatic/commit/67e77db2ca45ced28800b3f3165c656ee00854ec

the report was done through Discord, the seomatic_metabundles table had non-integer typeId column (NULL) which failed validation

bencroker commented 2 weeks ago

Ok, it doesn't tell me much but safe to assume this will resolve the issue in the next release of SEOmatic.