Fixed bug that commit failed when has no active transaction for polardb. (#5305)

This commit is contained in:
李铭昕 2023-01-09 16:28:48 +08:00 committed by GitHub
parent e976e54d5b
commit 28058e1a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 18 deletions

View File

@ -6,6 +6,7 @@
- [#5289](https://github.com/hyperf/hyperf/pull/5289) Fixed bug that `signal` cannot work when using `swow`.
- [#5303](https://github.com/hyperf/hyperf/pull/5303) Fixed bug that redis nsq adapter cannot work when topics is null.
- [#5305](https://github.com/hyperf/hyperf/pull/5305) Fixed bug that commit failed when has no active transaction for polardb.
## Optimized

View File

@ -2,12 +2,13 @@
# v3.0.1 - 2023-01-09
## Fixed
## 修复
- [#5289](https://github.com/hyperf/hyperf/pull/5289) 修复使用 `Swow` 引擎时,`Signal` 组件无法使用的问题。
- [#5303](https://github.com/hyperf/hyperf/pull/5303) 修复 `SocketIO``Redis NSQ 适配器`,当首次使用,`topics` 为 `null` 时,无法正常工作的问题。
- [#5305](https://github.com/hyperf/hyperf/pull/5305) 使用 `PolarDB` 读写分离时,修复因没有修改数据的情况下,提交事务会导致此链接存在异常,但又被回收进连接池的问题。
## Optimized
## 优化
- [#5287](https://github.com/hyperf/hyperf/pull/5287) 当服务端响应数据时,如果出现异常,则记录对应日志。
- [#5292](https://github.com/hyperf/hyperf/pull/5292) 为组件 `hyperf/metric` 增加 `Swow` 引擎的支持。

View File

@ -43,6 +43,7 @@ trait DetectsLostConnections
'Name or service not known',
'ORA-03114',
'Packets out of order. Expected',
'There is no active transaction',
]);
}
}

View File

@ -33,8 +33,6 @@ class Connection extends BaseConnection implements ConnectionInterface, DbConnec
protected LoggerInterface $logger;
protected bool $transaction = false;
public function __construct(ContainerInterface $container, DbPool $pool, protected array $config)
{
parent::__construct($container, $pool);
@ -106,7 +104,7 @@ class Connection extends BaseConnection implements ConnectionInterface, DbConnec
$this->connection->resetRecordsModified();
}
if ($this->isTransaction()) {
if ($this->transactionLevel() > 0) {
$this->rollBack(0);
$this->logger->error('Maybe you\'ve forgotten to commit or rollback the MySQL transaction.');
}
@ -114,16 +112,6 @@ class Connection extends BaseConnection implements ConnectionInterface, DbConnec
parent::release();
}
public function setTransaction(bool $transaction): void
{
$this->transaction = $transaction;
}
public function isTransaction(): bool
{
return $this->transaction;
}
/**
* Refresh pdo and readPdo for current connection.
*/

View File

@ -88,19 +88,16 @@ trait DbConnection
public function beginTransaction(): void
{
$this->setTransaction(true);
$this->__call(__FUNCTION__, func_get_args());
}
public function commit(): void
{
$this->setTransaction(false);
$this->__call(__FUNCTION__, func_get_args());
}
public function rollBack(): void
{
$this->setTransaction(false);
$this->__call(__FUNCTION__, func_get_args());
}

View File

@ -43,6 +43,7 @@ trait DetectsLostConnections
'Name or service not known',
'ORA-03114',
'Packets out of order. Expected',
'There is no active transaction',
]);
}
}