cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x]: 20+ DB writes from AssetManager per page load in the control panel

Open ericdrosas87 opened this issue 1 year ago • 0 comments

What happened?

Description

Upon logging into the Craft control panel, approximately 20 DB writes are made to the database by the AssetManager. Accordingly to @timkelty this should not be happening with each page request, though that is indeed what I am seeing.

We are hosting this in Google Cloud's Kubernetes Engine with Redis and the Google Cloud Storage plugin for assets and asset variants.

Apache info:

Server version: Apache/2.4.57 (Debian) Server built: 2023-04-13T03:26:51

Steps to reproduce

  1. Log into Craft control panel
  2. Enable debug panel for logged in user
  3. Open up the DB tab of the debug panel
  4. Navigate to a new control panel page to see the DB traffic

Alternatively for local dev:

  1. Add a Craft::info() log to the hash() function in craft\web\AssetManager to see the number of the upserts being performed with each request in the stdout log.
  2. tail -f the logs
  3. Navigate to different pages in the control panel to see the output in the logs, which for me looks like:
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @bower/jquery/dist {"memory":9891176} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @venveo/bulkedit/assetbundles/bulkeditelementaction/dist {"memory":9917872} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/cp/dist {"memory":9919904} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/tailwindreset/dist {"memory":9921888} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/axios/dist {"memory":9923904} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/d3/dist {"memory":9925872} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/elementresizedetector/dist {"memory":9927872} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/garnish/dist {"memory":9929920} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/jquerytouchevents/dist {"memory":9931904} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/velocity/dist {"memory":9933920} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/jqueryui/dist {"memory":9935936} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/jquerypayment/dist {"memory":9937952} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/picturefill/dist {"memory":9939968} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/selectize/dist {"memory":9941984} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/fileupload/dist {"memory":9944000} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/xregexp/dist {"memory":9946016} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/fabric/dist {"memory":9948000} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @craft/web/assets/iframeresizer/dist {"memory":9949984} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @modules/userregistrationmodule/assetbundles/userregistrationmodule/dist {"memory":9952032} 
2024-02-13 16:07:35 [web.INFO] [erosas] About to perform upsert for : @lsst/cantodamassets/web/assets/dist {"memory":9954112} 

These same upserts are seen with each page request and sometimes additional upserts are seen in the logs.

Expected behavior

Minimal if any DB writes per page request

Actual behavior

The same paths/hashes are passed to the upsert with almost every page request in the control panel.

Craft CMS version

4.5.4

PHP version

8.1

Operating system and version

Linux 5.15.65+

Database type and version

PostgreSQL 13.7

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

    "require": {
        "carlcs/craft-assetmetadata": "^4.0",
        "castiron/next-builds": "^1.0",
        "craftcms/cms": "4.5.4",
        "craftcms/contact-form": "3.0.1",
        "craftcms/contact-form-honeypot": "^2.0.0",
        "craftcms/generator": "^1.6",
        "craftcms/google-cloud": "^2.0.0",
        "craftcms/redactor": "3.0.4",
        "jamesedmonston/graphql-authentication": "2.5.0",
        "lsst-epo/canto-dam-assets": "4.0.9",
        "rynpsc/craft-phone-number": "^2.1.0",
        "sebastianlenz/linkfield": "^2.1.4",
        "spicyweb/craft-neo": "3.8.6",
        "venveo/craft-bulkedit": "4.0.1",
        "verbb/super-table": "3.0.9",
        "vlucas/phpdotenv": "^3.4.0",
        "wrav/oembed": "^2.2.2"
    },

ericdrosas87 avatar Feb 13 '24 17:02 ericdrosas87