We have a Magento 2.3.2 CE instance running and it has been working for us for a while without issue. Recently our products stopped saving and instead starting throwing the Asymmetric transaction rollback
error.
The only error being logged is the reference to the error line (Magento/Framework/DB/Adapter/Pdo/Mysql.php:324) without any further information.
I tried all the suggestions and fixes I could think of (or find online), including:
- Full Reindex (completed successfully)
- Cleared Cache (cache:flush, cache:clean)
- Manually removed
generated
,var/page_cache
,var/cache
- Changed indexers to run on schedule rather than save
- Verified search engine (elasticsuite) is running
- Changed search engine to MySql
- Ran the
setup:upgrade
andsetup:static-content:deploy
commands
After I tried these things and none of them changed, or fixed the error delved into the Magento code. After adding some logging and following the error through the logic I determined the error is being thrown due to a transaction being rolled back multiple times.
I was able to get my products to save again by changing:
public function rollBack()
{
if ($this->_transactionLevel === 1) {
$this->logger->startTimer();
parent::rollBack();
$this->_isRolledBack = false;
$this->logger->logStats(LoggerInterface::TYPE_TRANSACTION, 'ROLLBACK');
} elseif ($this->_transactionLevel === 0) {
throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE);
} else {
$this->_isRolledBack = true;
}
--$this->_transactionLevel;
return $this;
}
to
public function rollBack()
{
if ($this->_transactionLevel === 1) {
$this->logger->startTimer();
parent::rollBack();
$this->_isRolledBack = false;
$this->logger->logStats(LoggerInterface::TYPE_TRANSACTION, 'ROLLBACK');
} elseif ($this->_transactionLevel === 0) {
throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE);
} else {
//changed to false to allow products to save - NOT SURE OF SCOPE OF THIS CHANGE
$this->_isRolledBack = false;
}
--$this->_transactionLevel;
return $this;
}
Does anyone know what could be causing the problem originally, why this change has seemed to fix the issue for now, and if there are any (negative) side effects of making the change?