Answers.Body: <p>After a week of no luck, I was just about to ask this question, when I got a tip on the Town Square CiviCRM Matter Most forum (thank you @seamuslee)</p>
  <p>The entire problem was to do with Composer patches.  I did some more searching and found the answer here:</p>
  <p><a href="https://lab.civicrm.org/dev/core/-/issues/2198" rel="nofollow noreferrer">CiviMail &quot;DB error&quot;: suspected core bug relating to attachment replace api</a></p>
  <p>@Samuele.Masetto's answer of applying patches with the following line:</p>
  <pre><code>composer config extra.enable-patching true
  </code></pre>
  <p>A number of patches were added and the problem has gone away.  I hope this helps others as the issue seems to be intermittent.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-04T19:02:03.360Z
Answers.LastActivityDate: 2024-05-04T19:02:03.360Z
Answers.UserDisplayName: ChumKui
Body: <p>I updated from CiviCRM v5.70.2 to v5.73 (running Drupal 10.2.6, PHP 8.1 and MySQL 8).  During general upgrade testing, we run into an error with creating a test mailing in CiviMail.  This issue affects both Mosaico and Traditional mailings.  We get the following database error displayed:</p>
  <p><a href="https://i.sstatic.net/Ddu1SOb4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ddu1SOb4.png" alt="DB Error: unknown database" /></a></p>
  <p>I could find nothing in any of the usual logs (Drupal, CiviCRM, MySQL or Apache) and eventually took a look at the console:</p>
  <pre><code>Possibly unhandled rejection: {&quot;error_code&quot;:-1,&quot;sql&quot;:&quot;ROLLBACK TO SAVEPOINT civi_0&quot;,&quot;debug_info&quot;:&quot;ROLLBACK TO SAVEPOINT civi_0 [nativecode=1305 ** SAVEPOINT civi_0 does not exist]&quot;,&quot;entity&quot;:&quot;Attachment&quot;,&quot;action&quot;:&quot;get&quot;,&quot;is_error&quot;:1,&quot;error_message&quot;:&quot;DB Error: unknown error&quot;,&quot;debug_information&quot;:&quot;ROLLBACK TO SAVEPOINT civi_0&quot;}
  </code></pre>
  <p>and</p>
  <pre><code>Possibly unhandled rejection: {&quot;error_code&quot;:0,&quot;entity&quot;:&quot;Mailing&quot;,&quot;action&quot;:&quot;create&quot;,&quot;is_error&quot;:1,&quot;error_message&quot;:&quot;Mailing has not been saved, Content maybe out of date, please refresh the page and try again&quot;}
  </code></pre>
  <p>The issue seems to be to do with the temporary saving of the mailing. We see a brief 'saving' message in the top right hand corner and then the <code>DB Error: Unknown database</code> box appears. Any changes to the mailing that elicit a background save seems to cause this error.</p>
  <p>I had no idea what issue I was dealing with here - this seems to be to do with an Ajax request and Angular...</p>
  
Tags: <civimail><database><angular>
Title: DB Error: unknown database when creating a CiviMail mailing
ThreadText: # DB Error: unknown database when creating a CiviMail mailing
  
  (Asked by: username_0 on 2024-05-04)
  
  I updated from CiviCRM v5.70.2 to v5.73 (running Drupal 10.2.6, PHP 8.1 and MySQL 8).  During general upgrade testing, we run into an error with creating a test mailing in CiviMail.  This issue affects both Mosaico and Traditional mailings.  We get the following database error displayed:
  
  I could find nothing in any of the usual logs (Drupal, CiviCRM, MySQL or Apache) and eventually took a look at the console:
  Possibly unhandled rejection: {"error_code":-1,"sql":"ROLLBACK TO SAVEPOINT civi_0","debug_info":"ROLLBACK TO SAVEPOINT civi_0 [nativecode=1305 ** SAVEPOINT civi_0 does not exist]","entity":"Attachment","action":"get","is_error":1,"error_message":"DB Error: unknown error","debug_information":"ROLLBACK TO SAVEPOINT civi_0"}
  
  and
  Possibly unhandled rejection: {"error_code":0,"entity":"Mailing","action":"create","is_error":1,"error_message":"Mailing has not been saved, Content maybe out of date, please refresh the page and try again"}
  
  The issue seems to be to do with the temporary saving of the mailing. We see a brief 'saving' message in the top right hand corner and then the DB Error: Unknown database box appears. Any changes to the mailing that elicit a background save seems to cause this error.
  I had no idea what issue I was dealing with here - this seems to be to do with an Ajax request and Angular...
  
  **Tags:** civimail, database, angular
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-05-04. Score: 3 | Accepted answer
  
  After a week of no luck, I was just about to ask this question, when I got a tip on the Town Square CiviCRM Matter Most forum (thank you @seamuslee)
  The entire problem was to do with Composer patches.  I did some more searching and found the answer here:
  CiviMail "DB error": suspected core bug relating to attachment replace api
  @Samuele.Masetto's answer of applying patches with the following line:
  composer config extra.enable-patching true
  
  A number of patches were added and the problem has gone away.  I hope this helps others as the issue seems to be intermittent.
  
  
  ---
  
  