Postgres driver issue with nested savepoints mimic_implicit_commit duplicated

Created on 2 November 2017, about 7 years ago
Updated 9 February 2023, almost 2 years ago

We're having an issue with Workbench Moderation and Group installed and have traced it back to an issue with the Postgres db driver. The Postgres driver automatically creates savepoints named "mimic_implicit_commit" for most queries running inside of an ongoing transaction.

The problem occurs when a DB query is run that triggers another DB query in the first's preExecute() phase (typically a hook such as hook_node_grants). This creates a situation where a new savepoint also called "mimic_implicit_commit" is added before the original "mimic_implicit_commit" savepoint is released. pushTransaction() doesn't allow for duplicate savepoint names.

The easiest way to re-create is to install/enable Workbench Moderation and then have any module that implements hook_node_grants() with a DB query using the ->execute() method enabled as well (such as Group/Group Node). When you add try to add content as a user without "bypass node access", you'll get this error message when you try to save:

Drupal\Core\Entity\EntityStorageException: mimic_implicit_commit is already in use. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Here's some additional information about the problem. Basically all DB queries funnel into the pgsql\Select class's execute() method, which arbitrarily runs addSavepoint($savepoint_name = 'mimic_implicit_commit')

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...

# Drupal\Core\Database\Driver\pgsql\Select
public function execute() {
  $this->connection->addSavepoint();
  try {
    $result = parent::execute();
  }
  catch (\Exception $e) {
    $this->connection->rollbackSavepoint();
    throw $e;
  }
  $this->connection->releaseSavepoint();

  return $result;
}

pgsql\Select\execute() is called from many different places. Only one path via the pgsql/Connection query() method does it actually check for the duplicate 'mimic_implicit_commit' name:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...

# Drupal\Core\Database\Driver\pgsql\Connection
public function query($query, array $args = [], $options = []) {
  $options += $this->defaultOptions();

  // The PDO PostgreSQL driver has a bug which doesn't type cast booleans
  // correctly when parameters are bound using associative arrays.
  // @see http://bugs.php.net/bug.php?id=48383
  foreach ($args as &$value) {
    if (is_bool($value)) {
      $value = (int) $value;
    }
  }

  // We need to wrap queries with a savepoint if:
  // - Currently in a transaction.
  // - A 'mimic_implicit_commit' does not exist already.
  // - The query is not a savepoint query.
  $wrap_with_savepoint = $this->inTransaction() &&
    !isset($this->transactionLayers['mimic_implicit_commit']) &&
    !(is_string($query) && (
    stripos($query, 'ROLLBACK TO SAVEPOINT ') === 0 ||
    stripos($query, 'RELEASE SAVEPOINT ') === 0 ||
    stripos($query, 'SAVEPOINT ') === 0
    )
    );
  if ($wrap_with_savepoint) {
    // Create a savepoint so we can rollback a failed query. This is so we can
    // mimic MySQL and SQLite transactions which don't fail if a single query
    // fails. This is important for tables that are created on demand. For
    // example, \Drupal\Core\Cache\DatabaseBackend.
    $this->addSavepoint();
    try {
      $return = parent::query($query, $args, $options);
      $this->releaseSavepoint();
    }
    catch (\Exception $e) {
      $this->rollbackSavepoint();
      throw $e;
    }
  }
  else {
    $return = parent::query($query, $args, $options);
  }

  return $return;
}

However, both Groups and Workbench moderation call the pgsql/Select execute() method directly, bypassing the duplicate check for mimic_implicit_commit in pgsql/Connection query().

Groups:

#0  Drupal\Core\Database\Driver\pgsql\Select->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/DatabaseStorage.php:273]
#1  Drupal\Core\Config\DatabaseStorage->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/CachedStorage.php:207]
#2  Drupal\Core\Config\CachedStorage->findByPrefix() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/CachedStorage.php:183]
#3  Drupal\Core\Config\CachedStorage->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/ConfigFactory.php:328]
#4  Drupal\Core\Config\ConfigFactory->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/Entity/Query/Query.php:172]
#5  Drupal\Core\Config\Entity\Query\Query->loadRecords() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/Entity/Query/Query.php:82]
#6  Drupal\Core\Config\Entity\Query\Query->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php:503]
#7  Drupal\Core\Entity\EntityStorageBase->loadByProperties() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/group/src/GroupMembershipLoader.php:146]
#8  Drupal\group\GroupMembershipLoader->loadByUser() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/group/modules/gnode/gnode.module:169]

Workbench:

#0  Drupal\Core\Database\Driver\pgsql\Select->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php:250]
#1  Drupal\Core\Entity\Query\Sql\Query->result() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php:77]
#2  Drupal\Core\Entity\Query\Sql\Query->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/workbench_moderation/src/ModerationInformation.php:166]
#3  Drupal\workbench_moderation\ModerationInformation->getLatestRevisionId() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/workbench_moderation/src/ModerationInformation.php:151]

The pgsql driver may need to be patched to handle the duplicate savepoint condition when Query class's execute() function are accessed directly.

🐛 Bug report
Status

Needs work

Version

10.1

Component
PostgreSQL driver 

Last updated 5 days ago

No maintainer
Created by

🇨🇦Canada jeffdavidgordon

Live updates comments and jobs are added and updated live.
  • PostgreSQL

    Particularly affects sites running on the PostgreSQL database.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    As a bug this will need a test case to show the issue.
    Could the issue summary be updated to the default template showing proposed solution and remaining tasks please.
    Tagged for manual testing for someone who uses postgresql.

  • 🇮🇹Italy smarchese

    Thanks @ankithashetty the patch #26 🐛 Postgres driver issue with nested savepoints mimic_implicit_commit duplicated Needs work it's work for me!

  • 🇪🇸Spain abelass

    I can't apply #26 on 10.1

  • 🇺🇸United States jakegibs617

    adding a remake of 2920527-26.patch but fitting to druapl 10.2.2

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.2 & pgsql-14.1
    last update 12 months ago
    Custom Commands Failed
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & PostgreSQL 12.1
    last update 12 months ago
    Custom Commands Failed
  • 🇪🇸Spain abelass

    Thanks @jakegibs617 that works for me.

  • 🇺🇸United States jakegibs617

    @abelass are you able to clear the cache with the patch?
    when I run drush cr
    I am getting:
    A transaction named mimic_implicit_commit is already in use. Active stack: 65b129b004e365.44430355\drupal_transaction > 65b129b020e3c2.42669084\mimic_implicit_commit

    looking into it more now

  • 🇺🇸United States jakegibs617

    Can you give this one a shot? 2920527-37.patch

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & pgsql-14.1
    last update 12 months ago
    25,815 pass, 1,805 fail
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.2 & pgsql-14.1
    last update 12 months ago
    25,821 pass, 1,793 fail
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 12 months ago
    Build Successful
  • 🇪🇸Spain abelass

    @jakegibs617 sorry for my late answer, we only could test the patch yesterday. #37 worked fine in our tests, thanks.

  • First commit to issue fork.
  • 🇦🇺Australia elimw

    I updated Group contrib to 2.3.1 and noticed this issue. I applied patch #37 and even updated Core to 10.4.1 but neither fixed the issue.

  • First commit to issue fork.
  • 🇩🇪Germany vistree

    I see the same error after upgrading groups module and trying to migrate user realationship.

    [error]  Drupal\Core\Database\TransactionNameNonUniqueException: A transaction named mimic_implicit_commit is already in use. Active stack: 677fe54f644a06.04798895\drupal_transaction > 677fe54f67f767.51173260\mimic_implicit_commit in Drupal\Core\Database\Transaction\TransactionManagerBase->push() (line 254 of /var/www/docroot/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php).
    

    I tried patch from #37 - but this does not solve the error for me.

  • Pipeline finished with Failed
    11 days ago
    Total: 87s
    #391012
  • 🇫🇷France dydave

    Thanks a lot Jake (@jakegibs617) for the contributed patch above at #37, the great documentation of the issue and getting the ball rolling with this patch.

    I've tried to mention your work as much as possible in the MR to associate the credit.

    Quick follow-up:
    Created initial merge request above at #44:
    1 - Rolled in patch from #37

    2 - Added additional fix based on stack trace:

    Drupal\Core\Entity\EntityStorageException: A transaction named mimic_implicit_commit is already in use. Active stack: 677ffe0d432d66.20858170\drupal_transaction > 677ffe0d4c76f6.93298422\mimic_implicit_commit in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
    Drupal\pgsql\Driver\Database\pgsql\Connection->startTransaction('mimic_implicit_commit') (Line: 429)
    Drupal\pgsql\Driver\Database\pgsql\Connection->addSavepoint() (Line: 149)
    Drupal\pgsql\Driver\Database\pgsql\Schema->queryTableInformation('cache_flexible_permissions') (Line: 35)
    Drupal\pgsql\Driver\Database\pgsql\Upsert->execute() (Line: 312)
    Drupal\Core\Cache\DatabaseBackend->doSetMultiple(Array) (Line: 227)
    Drupal\Core\Cache\DatabaseBackend->setMultiple(Array) (Line: 211)
    Drupal\Core\Cache\DatabaseBackend->set('flexible_permissions:outsider:[user.roles]=authenticated', Object, -1, Array) (Line: 136)
    Drupal\Core\Cache\VariationCache->set(Array, Object, Object, Object) (Line: 172)
    Drupal\flexible_permissions\ChainPermissionCalculator->calculatePermissions(Object, 'outsider') (Line: 39)
    Drupal\group\Access\GroupPermissionCalculator->calculateFullPermissions(Object) (Line: 40)
    Drupal\group\QueryAccess\GroupQueryAlter->doAlter('view') (Line: 143)
    Drupal\group\QueryAccess\QueryAlterBase->alter(Object, Object) (Line: 333)
    group_query_entity_query_alter(Object, NULL, NULL) (Line: 552)
    Drupal\Core\Extension\ModuleHandler->alter('query', Object) (Line: 494)
    Drupal\Core\Database\Query\Select->preExecute() (Line: 519)
    Drupal\Core\Database\Query\Select->execute() (Line: 157)
    Drupal\pgsql\Driver\Database\pgsql\Select->execute() (Line: 272)
    Drupal\Core\Entity\Query\Sql\Query->result() (Line: 85)
    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 391)
    Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->validateReferenceableEntities(Array) (Line: 133)
    Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator->validate(Object, Object) (Line: 202)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Object, '0000000000000e150000000000000000', Array) (Line: 154)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 164)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 106)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, NULL, NULL) (Line: 93)
    Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object) (Line: 132)
    Drupal\Core\TypedData\TypedData->validate() (Line: 518)
    Drupal\Core\Entity\ContentEntityBase->validate() (Line: 25)
    Drupal\group\Entity\GroupMembership->preSave(Object) (Line: 528)
    Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
    Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 483)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 147)
    Drupal\group\Entity\Group->addRelationship(Object, 'group_membership', Array) (Line: 183)
    Drupal\group\Entity\Group->addMember(Object) (Line: 214)
    Drupal\CUSTOM->submitForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('free_trial_checkout_form', Array, Object) (Line: 326)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    Mostly :
    Drupal\pgsql\Driver\Database\pgsql\Schema->queryTableInformation('cache_flexible_permissions') (Line: 35)

    Tested and fixed issue in our project (similar versions mentioned above at #41) \o/
    ==> It probably still needs work, testing, but for now it fixes the issue in our project and allows us to move forward.

    Any reviews and feedback would be greatly appreciated.
    Thanks in advance!

  • 🇩🇪Germany vistree

    @dydave - is your MR expected to also solve the error on
    Drupal\Core\Database\TransactionNameNonUniqueException
    mentioned in #36 and #43?

  • 🇫🇷France dydave

    Thanks for the prompt feedback @vistree:

    is your MR expected to also solve the error on
    Drupal\Core\Database\TransactionNameNonUniqueException
    mentioned in #36 and #43?

    Really not sure about that, since we haven't come across this particular error.
    Could you please try providing a backtrace, similar to the one above at #45.

    Otherwise, perhaps more straight forward: Give the patch at:
    https://git.drupalcode.org/project/drupal/-/merge_requests/10859.diff
    a quick test and see if it fixes the issue in you project?

    Thanks Matthew (@mradcliffe) for the help reviewing and cleaning up the MR.
    Cheers!

  • Pipeline finished with Success
    11 days ago
    Total: 16725s
    #391114
  • 🇦🇺Australia elimw

    I have pushed a change to fix the issue I was encountering.

    Rather than having to explicitly check if we should wrap a query in a savepoint before calling "Connection::addSavepoint()", wouldn't it be better to do the check inside of "Connection::addSavepoint()" instead?

  • Pipeline finished with Success
    11 days ago
    Total: 10396s
    #391403
  • 🇩🇪Germany vistree

    @dydave - I found a backtrace in Watchdog. Is this helpfull? I am still on Drupal 10.4 by the way!! Error appears when trying to migrate Group User Relations with drush migrate:

    Drupal\Core\Database\TransactionNameNonUniqueException: A transaction named mimic_implicit_commit is already in use. Active stack: 677fb68df0dbc1.32969210\drupal_transaction > 677fb68df23611.91989256\mimic_implicit_commit in Drupal\Core\Database\Transaction\TransactionManagerBase->push() (Zeile 254 in /data/html/docroot/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php).

    #0 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php(558): Drupal\Core\Database\Transaction\TransactionManagerBase->push()
    #1 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php(431): Drupal\pgsql\Driver\Database\pgsql\Connection->startTransaction()
    #2 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Schema.php(149): Drupal\pgsql\Driver\Database\pgsql\Connection->addSavepoint()
    #3 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php(35): Drupal\pgsql\Driver\Database\pgsql\Schema->queryTableInformation()
    #4 /data/html/docroot/core/lib/Drupal/Core/Cache/DatabaseBackend.php(312): Drupal\pgsql\Driver\Database\pgsql\Upsert->execute()
    #5 /data/html/docroot/core/lib/Drupal/Core/Cache/DatabaseBackend.php(227): Drupal\Core\Cache\DatabaseBackend->doSetMultiple()
    #6 /data/html/docroot/core/lib/Drupal/Core/Cache/DatabaseBackend.php(215): Drupal\Core\Cache\DatabaseBackend->setMultiple()
    #7 /data/html/docroot/core/lib/Drupal/Core/Cache/VariationCache.php(176): Drupal\Core\Cache\DatabaseBackend->set()
    #8 /data/html/docroot/modules/contrib/flexible_permissions/src/ChainPermissionCalculator.php(172): Drupal\Core\Cache\VariationCache->set()
    #9 /data/html/docroot/modules/contrib/group/src/Access/GroupPermissionCalculator.php(39): Drupal\flexible_permissions\ChainPermissionCalculator->calculatePermissions()
    #10 /data/html/docroot/modules/contrib/group/src/QueryAccess/GroupQueryAlter.php(40): Drupal\group\Access\GroupPermissionCalculator->calculateFullPermissions()
    #11 /data/html/docroot/modules/contrib/group/src/QueryAccess/QueryAlterBase.php(143): Drupal\group\QueryAccess\GroupQueryAlter->doAlter()
    #12 /data/html/docroot/modules/contrib/group/group.module(333): Drupal\group\QueryAccess\QueryAlterBase->alter()
    #13 /data/html/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): group_query_entity_query_alter()
    #14 /data/html/docroot/core/lib/Drupal/Core/Database/Query/Select.php(494): Drupal\Core\Extension\ModuleHandler->alter()
    #15 /data/html/docroot/core/lib/Drupal/Core/Database/Query/Select.php(519): Drupal\Core\Database\Query\Select->preExecute()
    #16 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Select.php(157): Drupal\Core\Database\Query\Select->execute()
    #17 /data/html/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(272): Drupal\pgsql\Driver\Database\pgsql\Select->execute()
    #18 /data/html/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(85): Drupal\Core\Entity\Query\Sql\Query->result()
    #19 /data/html/docroot/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php(401): Drupal\Core\Entity\Query\Sql\Query->execute()
    #20 /data/html/docroot/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraintValidator.php(133): Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->validateReferenceableEntities()
    #21 /data/html/docroot/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(202): Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator->validate()
    #22 /data/html/docroot/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(154): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints()
    #23 /data/html/docroot/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(164): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode()
    #24 /data/html/docroot/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(106): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode()
    #25 /data/html/docroot/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php(93): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate()
    #26 /data/html/docroot/core/lib/Drupal/Core/TypedData/TypedData.php(132): Drupal\Core\TypedData\Validation\RecursiveValidator->validate()
    #27 /data/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityBase.php(518): Drupal\Core\TypedData\TypedData->validate()
    #28 /data/html/docroot/modules/contrib/group/src/Entity/GroupMembershipTrait.php(25): Drupal\Core\Entity\ContentEntityBase->validate()
    #29 /data/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(528): Drupal\group\Entity\GroupMembership->preSave()
    #30 /data/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(753): Drupal\Core\Entity\EntityStorageBase->doPreSave()
    #31 /data/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave()
    #32 /data/html/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(806): Drupal\Core\Entity\EntityStorageBase->save()
    #33 /data/html/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
    #34 /data/html/docroot/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php(237): Drupal\Core\Entity\EntityBase->save()
    #35 /data/html/docroot/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php(175): Drupal\migrate\Plugin\migrate\destination\EntityContentBase->save()
    #36 /data/html/docroot/core/modules/migrate/src/MigrateExecutable.php(248): Drupal\migrate\Plugin\migrate\destination\EntityContentBase->import()
    #37 /data/html/vendor/drush/drush/includes/drush.inc(62): Drupal\migrate\MigrateExecutable->import()
    #38 /data/html/vendor/drush/drush/includes/drush.inc(53): drush_call_user_func_array()
    #39 /data/html/docroot/modules/contrib/migrate_tools/src/Drush/Commands/MigrateToolsCommands.php(1074): drush_op()
    #40 /data/html/docroot/modules/contrib/migrate_tools/src/Drush/Commands/MigrateToolsCommands.php(483): Drupal\migrate_tools\Drush\Commands\MigrateToolsCommands->executeMigration()
    #41 [internal function]: Drupal\migrate_tools\Drush\Commands\MigrateToolsCommands->import()
    #42 /data/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
    #43 /data/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
    #44 /data/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
    #45 /data/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
    #46 /data/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
    #47 /data/html/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run()
    #48 /data/html/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
    #49 /data/html/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
    #50 /data/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
    #51 /data/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
    #52 /data/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
    #53 /data/html/vendor/drush/drush/drush(4): require('/data/html/docr...')
    #54 /data/html/vendor/bin/drush(119): include('/data/html/docr...')
    #55 {main}
  • 🇫🇷France dydave

    Nice one @vistree!

    I am still on Drupal 10.4 by the way!! Therefor patch https://git.drupalcode.org/project/drupal/-/merge_requests/10859.diff will not apply.

    Just did the test with D10.4.1 and the patch applies very well.

    Additionally, looking at your stack trace, see:
    #3 /data/html/docroot/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php(35): Drupal\pgsql\Driver\Database\pgsql\Schema->queryTableInformation()

    Same as pointed above at #45.

    Therefore: The patch should apply and fix the issue for your project! \o/

    Could you please do a quick round of test and report back?

    Thanks in advance!

  • 🇫🇷France dydave

    Thanks Elim (@elimw), re #48:

    Rather than having to explicitly check if we should wrap a query in a savepoint before calling "Connection::addSavepoint()", wouldn't it be better to do the check inside of "Connection::addSavepoint()" instead?

    Sounds good! I'm not super familiar with the overall code of the pgsql module, but if you do a quick search around and see where the functions are used and if there would be any unexpected impacts, it would be great!

    Could you perhaps create a new merge request with a different patch?
    We would be able to give the patch a round of tests and see if it could be equivalent to the current MR!10859.

    Thanks in advance!

  • 🇩🇪Germany vistree

    @dydave -After upgrading to current Drupal core 10.4.1 patch from MR (https://git.drupalcode.org/project/drupal/-/merge_requests/10859.diff) applied and - what great news - solved the error on running my migration ;-)

    So, I can confirm that the MR solves the error regarding "Drupal\Core\Database\TransactionNameNonUniqueException" on group relationship migrations.

  • 🇫🇷France dydave

    Thanks a lot @vistree for the feedback! Glad it's working for you 🥳

    Hopefully we'll get more reviews, feedback and perhaps a better version of the patch (see #51/refactoring), but for now, hopefully, this version will allow all of us to keep moving forward on our projects!
    Cheers!

  • 🇦🇺Australia elimw

    @dydave, @vistree, I've created separate MR which checks if a savepoint with the same name already exists before pushing a transaction.

  • Pipeline finished with Failed
    7 days ago
    Total: 6869s
    #395219
  • 🇩🇪Germany vistree

    @elimw: is your MR a replacement or an addition for MR 10859 ?

  • 🇫🇷France dydave

    Thanks a lot Elim (@elimw)! Great job!

    We've just given a round of tests with the merge request you created MR!10896 and it fixed the issue as well for us 🥳
    We've updated the patch in our project to use the one from #54.

    @vistree:
    Yes indeed, the patch created by Elim can be tested here:
    https://git.drupalcode.org/project/drupal/-/merge_requests/10896.diff

    It should fix the issue in your project as well.

    It's a different (better) way of writing the same thing as the previous patch.

    Thanks again for the work Elim and in advance for your feedback @vistree!

  • 🇺🇸United States mradcliffe USA

    The merge request 10896 (#45) seems to be 1770 commits behind the target branch and needs a rebase. It's currently failing tests.

    The issue is a little hard to follow and I think next if someone could address the Needs issue summary update tag that would be helpful to clarify proposed resolutions and remaining tasks.

  • Pipeline finished with Failed
    6 days ago
    #396013
  • Pipeline finished with Success
    6 days ago
    Total: 5803s
    #396014
  • 🇨🇦Canada andrew.wang

    https://git.drupalcode.org/project/drupal/-/merge_requests/10859.diff solved this issue for me after installing entity_reference_integrity on Drupal 10.3.10.

    https://git.drupalcode.org/project/drupal/-/merge_requests/10896.diff also worked!

  • 🇫🇷France dydave

    @mradcliffe: Both merge requests have been rebased.

    Issue summary still needs to be updated.

    Thanks!

  • Pipeline finished with Success
    6 days ago
    Total: 521s
    #396436
  • 🇩🇪Germany vistree

    I can confirm that also the MR https://git.drupalcode.org/project/drupal/-/merge_requests/10896.diff solves the error regarding "Drupal\Core\Database\TransactionNameNonUniqueException" on group relationship migrations.

Production build 0.71.5 2024