Body: <p>I keep seeing a Craft 3 site with queue sticking and clearing the cache doesn't clear it.</p>
  
  <p>I have been thru plugins fixed some errors and now it all comes down to same issues:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]</p>
  </blockquote>
  
  <p>The specifics are:</p>
  
  <pre><code>    thrown in /home/mydomain/vendor/yiisoft/yii2/web/Response.php on line 366
  [30-Oct-2019 19:21:47 UTC] PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 413696 bytes) in /home/mydomain/vendor/  
  yiisoft/yii2/db/Command.php on line 1290
  [30-Oct-2019 19:21:47 UTC] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered   queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in /home/mydomain/vendor/yiisoft/yii2/db/Command.php:1290
  Stack trace:
  #0 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(1290): PDOStatement-&gt;execute()
  #1 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(1158): yii\db\Command-&gt;internalExecute('SELECT *\nFROM `...')
  #2 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(399): yii\db\Command-&gt;queryInternal('fetchAll', NULL)
  #3 /home/mydomain/vendor/yiisoft/yii2/db/Query.php(237): yii\db\Command-&gt;queryAll()
  #4 /home/mydomain/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query-&gt;all(NULL)
  #5 /home/mydomain/vendor/craftcms/cms/src/services/Categories.php(125): yii\db\ActiveQuery-&gt;all()
  #6 /home/mydomain/vendor/craftcms/cms/src/service in /home/mydomain/vendor/craftcms/cms/src/templates/_layouts/base.html on line 37
  </code></pre>
  
  <p>I am not sure how to resolve this. Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-21T06:42:09.007Z
Comments.Text: I have the same issue with craft_templatecachequeries. It is already 1Gb.  Is no pending jobs. Any knowing solutions? Craftcms 3.4.7.1
Comments.UserDisplayName: Max Lazar
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-21T10:07:40.857Z
Comments.Text: Hey Max. I eventually solved this by removing certain cache tags in my templates. I started with menu navigation tags first then worked down to page level. Kinda puzzling and never got to the bottom of it other than Brads advice which was to start stripping them out.i
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-31T19:32:36.503Z
Comments.Text: What job is it trying to complete when that happens?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-01T14:00:50.737Z
Comments.Text: It's always clearing template caches...
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-11T11:09:22.080Z
Comments.Text: Is this still an issue? Does it happen on a different environment?
Comments.UserDisplayName: dmatthams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-12T16:07:24.040Z
Comments.Text: It happens in production only (staging is on same server) - seems something to do with content requests and template creation but cant find any more useful errors
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-13T11:42:46.963Z
Comments.Text: That's interesting, do you have cache enabled on production and disabled on staging? I've had mysterious errors with cache that were solved by increasing max_allowed_packet in my.conf. If not what else is enabled on production and not on staging?
Comments.UserDisplayName: dmatthams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-13T15:27:47.130Z
Comments.Text: Now were' getting somewhere - 'craft_templatecachequeries' is running at 2 gig in size and not clearing which might be hard to clear in a background task. I noticed in production config that I'd set cacheElementQueries to true though its the cacheElementQueries table that is filling up, i wonder if this setting uses that table? I probably set it for performance reasons. This might be it
Comments.UserDisplayName: joomkit
Tags: <queue><stalled-tasks>
Title: Craft queue keeps sticking despite 1GB memory allocation
ThreadText: # Craft queue keeps sticking despite 1GB memory allocation
  
  (Asked by: username_0 on 2019-10-31)
  
  I keep seeing a Craft 3 site with queue sticking and clearing the cache doesn't clear it.
  
  I have been thru plugins fixed some errors and now it all comes down to same issues:
  
  > PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]
  
  The specifics are:
  
  ```
      thrown in /home/mydomain/vendor/yiisoft/yii2/web/Response.php on line 366
  [30-Oct-2019 19:21:47 UTC] PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 413696 bytes) in /home/mydomain/vendor/  
  yiisoft/yii2/db/Command.php on line 1290
  [30-Oct-2019 19:21:47 UTC] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered   queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in /home/mydomain/vendor/yiisoft/yii2/db/Command.php:1290
  Stack trace:
  #0 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(1290): PDOStatement->execute()
  #1 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(1158): yii\db\Command->internalExecute('SELECT *\nFROM `...')
  #2 /home/mydomain/vendor/yiisoft/yii2/db/Command.php(399): yii\db\Command->queryInternal('fetchAll', NULL)
  #3 /home/mydomain/vendor/yiisoft/yii2/db/Query.php(237): yii\db\Command->queryAll()
  #4 /home/mydomain/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query->all(NULL)
  #5 /home/mydomain/vendor/craftcms/cms/src/services/Categories.php(125): yii\db\ActiveQuery->all()
  #6 /home/mydomain/vendor/craftcms/cms/src/service in /home/mydomain/vendor/craftcms/cms/src/templates/_layouts/base.html on line 37
  
  ```
  
  I am not sure how to resolve this. Any ideas?
  
  **Tags:** queue, stalled-tasks
  
  > **Comments:**
  > **username_2**: What job is it trying to complete when that happens?  
  > **username_0**: It's always clearing template caches...  
  > **username_3**: Is this still an issue? Does it happen on a different environment?  
  > **username_0**: It happens in production only (staging is on same server) - seems something to do with content requests and template creation but cant find any more useful errors  
  > **username_3**: That's interesting, do you have cache enabled on production and disabled on staging? I've had mysterious errors with cache that were solved by increasing max_allowed_packet in my.conf. If not what else is enabled on production and not on staging?  
  > **username_0**: Now were' getting somewhere - 'craft_templatecachequeries' is running at 2 gig in size and not clearing which might be hard to clear in a background task. I noticed in production config that I'd set cacheElementQueries to true though its the cacheElementQueries table that is filling up, i wonder if this setting uses that table? I probably set it for performance reasons. This might be it  
  > **username_1**: I have the same issue with craft_templatecachequeries. It is already 1Gb.  Is no pending jobs. Any knowing solutions? Craftcms 3.4.7.1  
  > **username_0**: Hey Max. I eventually solved this by removing certain cache tags in my templates. I started with menu navigation tags first then worked down to page level. Kinda puzzling and never got to the bottom of it other than Brads advice which was to start stripping them out.i  
  
  ---
  
  ## 0 answers
  
  