Answers.Body: <p>When a task actually fails (as opposed to getting <a href="http://buildwithcraft.com/help/stuck-tasks" rel="noreferrer">stuck</a>), Craft will log an error message explaining why. To fish it up, open craft/storage/runtime/logs/craft.log, and search for:</p>
  
  <pre><code>Encountered an error running task
  </code></pre>
  
  <p>Each time the task runner encounters an error, its log message will begin with that, followed by the task’s ID, its type, which step it was on (if applicable), and the error message the actual task returned.</p>
  
  <p>If you’re not seeing it, check craft.log.1, craft.log.2, etc.  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-24T13:15:26.587Z
Answers.Text: Hi, Brandon! I updated the original question with what looks to be the error. Any thoughts on eliminating it? As a further, tangential follow-up, I've actually been asked to randomize these rather than sort by date. Is that possible? Is it possible within cached template code? Thanks!
Answers.UserDisplayName: Mark J. Reeves
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-24T13:18:05.720Z
Answers.Text: @MarkJ.Reeves Hey Mark, can you split this up into multiple questions? I answered your first one; understanding how to fix the specific SQL error you’re getting would be another, and the randomization question would be a third. (The best way to ensure that this content will be discoverable and helpful for others down the road is to give each question its own Q&A thread.)
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-24T11:55:06.990Z
Answers.LastActivityDate: 2014-10-24T17:28:13.217Z
Answers.LastEditDate: 2014-10-24T17:28:13.217Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I continue to see these pile up. If I clear my template cache, I can hit retry on each and they go away, but that's getting tedious.</p>
  <p><img src="https://i.sstatic.net/PNUVT.png" alt="enter image description here" /></p>
  <p>I have the following from a P&amp;T support request on these a while back, but is there any way to track down where/why these are happening now? I'm not seeing any deprecated tag errors or anything in the CP, nor am I seeing any template errors on the site, and I have a fair number of pages cached where images are being resized.</p>
  <blockquote>
  <p>Hrm... I see the error that's occurring in your log files when that task tries to complete. What looks like happened was that there was an error in your Twig code somewhere inside of one of your {% cache %} tags and that error actually got cached and saved to the database and that is freaking the DeleteStaleTemplatesCache task out.</p>
  <p>Kinda hard to back track which cache tag it occurred in and what part of your template code.</p>
  <p>But the way to get it worked again is to clear your template caches manually from Settings-&gt;Tools. You should be able to click &quot;retry&quot; on those failed tasks again and they should complete fine.</p>
  </blockquote>
  <p>Thanks!</p>
  <p>Mark</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-23T17:55:09.333Z
Comments.Text: I looked, but couldn't find the ticket you were referring to. Did we share what the error in the logs was?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-24T12:31:49.193Z
Comments.Text: No, that's all I had. It was July 21st of this year. I'll follow up on Brandon's suggestion. Thanks!
Comments.UserDisplayName: Mark J. Reeves
Tags: <control-panel><cache>
Title: Deleting Stale Template Caches Failed
ThreadText: # Deleting Stale Template Caches Failed
  
  (Asked by: username_0 on 2014-10-23)
  
  I continue to see these pile up. If I clear my template cache, I can hit retry on each and they go away, but that's getting tedious.
  
  ![enter image description here](https://i.sstatic.net/PNUVT.png)
  
  I have the following from a P&T support request on these a while back, but is there any way to track down where/why these are happening now? I'm not seeing any deprecated tag errors or anything in the CP, nor am I seeing any template errors on the site, and I have a fair number of pages cached where images are being resized.
  
  > Hrm... I see the error that's occurring in your log files when that task tries to complete. What looks like happened was that there was an error in your Twig code somewhere inside of one of your {% cache %} tags and that error actually got cached and saved to the database and that is freaking the DeleteStaleTemplatesCache task out.
  >
  > Kinda hard to back track which cache tag it occurred in and what part of your template code.
  >
  > But the way to get it worked again is to clear your template caches manually from Settings->Tools. You should be able to click "retry" on those failed tasks again and they should complete fine.
  
  Thanks!
  
  Mark
  
  **Tags:** control-panel, cache
  
  > **Comments:**
  > **username_1**: I looked, but couldn't find the ticket you were referring to. Did we share what the error in the logs was?  
  > **username_0**: No, that's all I had. It was July 21st of this year. I'll follow up on username_2's suggestion. Thanks!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-10-24. Score: 6 | Accepted answer
  
  When a task actually fails (as opposed to getting [stuck](http://buildwithcraft.com/help/stuck-tasks)), Craft will log an error message explaining why. To fish it up, open craft/storage/runtime/logs/craft.log, and search for:
  
  ```
  Encountered an error running task
  
  ```
  
  Each time the task runner encounters an error, its log message will begin with that, followed by the task’s ID, its type, which step it was on (if applicable), and the error message the actual task returned.
  
  If you’re not seeing it, check craft.log.1, craft.log.2, etc.
  
  > **Comments:**
  > **username_0**: Hi, username_2! I updated the original question with what looks to be the error. Any thoughts on eliminating it? As a further, tangential follow-up, I've actually been asked to randomize these rather than sort by date. Is that possible? Is it possible within cached template code? Thanks!  
  > **username_2**: @username_0 Hey Mark, can you split this up into multiple questions? I answered your first one; understanding how to fix the specific SQL error you’re getting would be another, and the randomization question would be a third. (The best way to ensure that this content will be discoverable and helpful for others down the road is to give each question its own Q&A thread.)  
  
  ---
  
  