I am getting this error with 7.15. They are consistently happening in pairs. I'm using mysql. Note this is

php

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in file_usage_add() (line 661 of /var/www/website.com/includes/file.inc).

node

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in file_usage_add() (line 661 of /var/www/buyagainbaby.com/includes/file.inc).

I originally posted about this in a related thread http://drupal.org/comment/edit/6556106.

Issue fork drupal-1803886

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tuccio’s picture

Similar error here:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in CommerceOrderEntityController->save() (line 104 of /sites/all/modules/commerce/modules/order/includes/commerce_order.controller.inc).

ParisLiakos’s picture

somatics’s picture

You closed my other ticket (referenced above) as a duplicate of this one. But you also filed this one under Drupal version 8. My site runs 7. Is the resolution to this issue going to help Drupal 7?

ParisLiakos’s picture

Its resolution will have to get through drupal 8 first and then backported to drupal 7

somatics’s picture

Respectfully, if this is a major bug (it is for us) in 7, isn't it important to get treated as such? I'm concerned that it will just be on a long list in developing 8, since 8 is a long way to production status, whereas in a live 7 site, it's a much more immediate priority -- for example, we can't even create new content types, which is critical for our site right now.

ParisLiakos’s picture

I didnt mention that this will have to wait until drupal 8 is released.
Just that this fix will have to committed to drupal 8 repository and then drupal 7..that helps the two branches being in sync and ensures all bugs fixed in drupal 7 are fixed in drupal 8 as well.

Letharion’s picture

I came here because in apachesolr_entity_update() I got the same error message from the ->execute() line at the end of the function.

In my case it's not repeatable though. I'm creating a million nodes on a daily basis, and I've only seen this message a single time. (It could have happened more often and I haven't noticed though).

Gastonia’s picture

To answer @2, it seems that this is still an issue. I was asked to create a new thread instead of continuing the old one.

As of this writing, I get this error still quite often. Now running D7.16 with all modules up to date. Let me know if you would like me to provide any more details.

Letharion’s picture

FileSize
467 bytes

I've hacked my core with the following patch to get some better debug data out. But after I applied it the error stopped reproducing >_<. Uploading in here so others with the issue can try applying it as well.

marcus_clements’s picture

We are also seeing this error several times a day.

xjm’s picture

Issue tags: +Needs backport to D7
alanom’s picture

So, issue summary - this bug appears often, and 2 months in, no-one has any idea what is causing it. Correct me if wrong.

For what it's worth, I usually see this error when field-related actions (e.g. deleting nodes) happen concurrently.

catch’s picture

If you're getting this error, please post your MySQL version.

http://bugs.mysql.com/bug.php?id=38187 looks like a possible issue if you're running 5.0.*

alanom’s picture

MySQL 5.0.95 for me, so one sample in, that's a possibility. Looks like it was 5.1.33 that the posted bug was fixed in.

Gastonia’s picture

Running mysql --version I get:

mysql Ver 14.14 Distrib 5.5.28, for debian-linux-gnu (x86_64) using readline 6.2

Gastonia’s picture

@alanomoly #12 - I agree that this is a concurrency issue. Our errors happen when people are trying to post (save) nodes concurrently instead of delete. still happening as of mysql 5.5.28 and drupal 7.17

neRok’s picture

Marked #1792918: SAVEPOINT error in file_usage_add as duplicate of this issue.

carn1x’s picture

Getting a similar error:

Sep 17 07:32:34 ip-10-136-121-12 drupal: http://www.site.com|1379403122|node|127.0.0.1|http://www.site.com/sites/all/modules/contrib/elysia_cron/cron.php?cron_key=xxx||0||PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array#012(#012)#012 in EntityAPIController->save() (line 486 of /sites/all/modules/contrib/entity/includes/entity.controller.inc).

MySQL is newer than #13 is hoping for:

$ mysql --version
mysql  Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (x86_64) using readline 6.2
braindrift’s picture

Have a similar error message:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in node_save() (line 1198 of /var/www/htdocs/.../modules/node/node.module).

The error doesn't appear if I change the storage engine of the table file_usage from InnoDB to MyISAM

j0rd’s picture

Same problem. Happens for me during feeds import, with apachesolr running on Drush.

Array() in apachesolr_entity_update() (line 1832 of  sites/all/modules/contrib/apachesolr/apachesolr.module).
WD node: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1;       

MySQL 5.1, PHP 5.3.

RunePhilosof’s picture

@dendie that would probably be because MyISAM doesn't support transactions.

Erik.Johansson’s picture

This error occurs for me when a order is created.
The server is running mysql version mysql 14.14 Distrib 5.5.34.
Drupal 7.23
PHP 5.3.10

Anonymous’s picture

we are also getting this sporadically when viewing or editting a node (we have tracker enabled).

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array
(
)
in _tracker_add() (line 264 of /home/km/modules/tracker/tracker.module).

as per comment #13.

Drupal 7.22
php 5,3,27
mysql 5.1.67

pounard’s picture

Issue summary: View changes
FileSize
862 bytes

I still experience this issue too. This indeed seems to happen during in concurrency scenarios.

Code like this:

try {
  $tx = db_transaction();
  ... // Dobusiness stuff
} catch (Exception $e) {
  if (isset($tx)) {
    $tx->rollback();
  }
  throw $e;
}

Will sadly loose the current exception when another happens during rollback.

While a better algorithm such as:

$tx = null;
try {
  $tx = db_transaction();
  ... // Do business stuff
  unset($tx); // Explicit commit
} catch (Exception $e) {
  if ($tx) {
    try {
      $tx->rollback();
    } catch (Exception $e2) {}
  }
  throw $e;
}

Will catch the real business error and tell us what we need to know.

Which makes me think that the SQLSTATE[42000] ... 1305 SAVEPOINT ... error we all experience are actually hiding the real exception behing, and for some reason, probably a poorly coded algorithm somewhere or a MySQL bug, we cannot solve the real cause, which in concurrency scenarios could be a concurrent transaction deadlock timeout reached instead.

Meanwhile, I did a very simple patch that should unhide the original exception that did trigger the rollback by using the attached patch.

The attached patch was made using SVN diff so please apply it manually and not with git. Please also note it has been made on a 7.15 core.

pounard’s picture

Oups wrong patch attached.

N1ghteyes’s picture

im also getting the issue, currently its occuring when uploading files, and changing the state of checkboxes at the same time, while trying to update a node from a custom form.

Drupal 7.32-dev

jhedstrom’s picture

Status: Active » Needs review

#25 should be at needs review.

The last submitted patch, 9: dd_in_bootstrap.patch, failed testing.

The last submitted patch, 24: 1803886-24-rollback_to_savepoint.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 25: 1803886-25-rollback_to_savepoint.patch, failed testing.

ufku’s picture

Version: 8.0.x-dev » 7.x-dev
Priority: Major » Normal
Status: Needs work » Active
Issue tags: -Needs backport to D7

Can anyone reproduce this in 8.x? "bugs should be fixed in HEAD first" but we don't have any evidence that it exists in 8.x

lhridley’s picture

Rerolling patch from comment 25:

lhridley’s picture

Status: Active » Needs review
akolahi’s picture

I was receiving this error when using VBO on large numbers of items. The error would cause the batch process to stop. While I don't understand the root cause of the error, the above patch #32 does appear to allow my VBO batches to process without failing.

Thank you.

Andy_D’s picture

Seen in Drupal 7.44 & MySQL 5.5.52-0ubuntu0.14.04.1-log (Ubuntu)

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in EntityAPIController->save() (line 481 of .../entity/includes/entity.controller.inc).

followed by

SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist

I have applied patch #32 and will monitor for any re-occurrence - thanks pounard & lhridley!

tim.plunkett’s picture

Version: 7.x-dev » 8.5.x-dev

I am able to reproduce in D8 with patches from #933004: Test that all form elements have a title for accessibility, wherein I do a lot of entity creation and some exception catching.

dunx’s picture

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in EntityAPIController->save() (line 481 of [snip]/entity.controller.inc).

When trying to create a user account.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

flocondetoile’s picture

Recently had this issue too. On a commerce product (core 8.4.4, commerce 2.3). Seems this occurs simply by visiting the page.

AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /mysite/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 805\n'

mr.baileys’s picture

Same issue, Drupal 8.5.2, MySQL 5.7.17

Attempt to port the patch from #32 to D8

mahtab_alam’s picture

Version: 8.6.x-dev » 8.5.x-dev
FileSize
828 bytes

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anbarasan.r’s picture

+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -1111,7 +1111,13 @@ public function rollBack($savepoint_name = 'drupal_transaction') {
+        } catch (PDOException $e) {

This should be } catch (\PDOException $e) {, missing \ before PDOException

anbarasan.r’s picture

Made that specific change and re rolling that patch against 8.6.x

anbarasan.r’s picture

Fixing CS issue and removing other line

aditya.ghan’s picture

Hi All,

I tried the patch #45, it seems to me that the issue still exists.

I'm facing this issue while saving content randomly on Drupal 8.5. Does anyone else still face the same issue?

Thanks for your help!
Adi

rajeevk’s picture

Status: Needs review » Needs work

Need work as patch provided in #45 doesn't solve the issue. It's still occurring for content type with Paragraph fields. Thanks

Rhino-new’s picture

I've applied patch #32 but still get this error

PDOException: SQLSTATE[HY000]: General error: user-supplied statement does not accept constructor arguments: ROLLBACK TO SAVEPOINT savepoint_1; Array ( ) in EntityAPIController->save() (line 481 of /sites/all/modules/entity/includes/entity.controller.inc).

I have

Drupal 7.65
PHP 7.2.15
mysql 5.7.25

Specific modules used when this happens:
video
paragraphs

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

karthikeyan-manivasagam’s picture

this happened for us while updating paragraph update version 8018, still facing the same.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

parasolx’s picture

Patch # 32 has fixed my Drupal 7 error. I'm testing a load test with 200 concurrent users to create a node programmatically through an API request. Almost 3 or 5 bugs occur before patching. Once patched, the entire request was successfully created in the database.

shubhangi1995’s picture

when trying to save node in hook_comment_insert -> the issue is still there in core: 8.9

TrevorBradley’s picture

To anyone hitting this - we were doing some load testing on a server and hit the "savepoint_1" error hard. It wasn't consistent, but it was reproducible under load.

One of the problems diagnosing savepoint_1 appears to be that SqlContentEntityStorage::save() calls $transaction->rollBack(); as part of an Exception catch. $transaction->rollBack() runs a number of commands that come around and run SqlContentEntityStorage::save() AGAIN. This time around, the savepoint_1 error is hit and the system dies and logs savepoint_1.

savepoint_1 is likely a red herring - you need to figure out what the original exception was that triggers the rollback in the first place.

We fixed this by swapping the order of the rollback and watchdog_exception, changing this:

    catch (\Exception $e) {
      $transaction->rollBack();
      watchdog_exception($this->entityTypeId, $e);
      throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
    }

to this:

    catch (\Exception $e) {
      watchdog_exception($this->entityTypeId, $e);
      $transaction->rollBack();
      throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
    }

For us, this looks like it's a SQL Deadlock issue, as described in #2833539: SQLSTATE[40001]: Serialization failure: 1213 Deadlock

I'm not sure I'd advocate for a patch that swaps the order of watchdog_exception() and rollBack(), as watchdog_exception has to log to the database as well, but if you're trying to crack this problem, look here first.

TL;DR: If you see a savepoint_1 error, it's likely masking some other error that's getting lost in the catch block of SqlContentEntityStorage::save().

BenjaminLeibinger’s picture

ptmkenny’s picture

Version: 8.9.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

skrug’s picture

Hi, I made a patch for Drupal 9.3.x based on the patch of comment #55 because the source code in Drupal 9.3.x is a little bit different.

Shashwat Purav’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Artusamak made their first commit to this issue’s fork.

Artusamak’s picture

Rerolled patch for 9.4.x in MR !3105.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kerasai made their first commit to this issue’s fork.

anrikun’s picture

As pointed out at #54, this patch is absolutely not a viable solution. Logging exception before rolling back transaction basically means that the exception won't be logged.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.