Symfony 3.4和MySQL 8。一般错误:2006 MySQL Server在RabbitMQ队列中运行交易时已经消失
我有一个系统(Symfony 5,Symfony/Messenger)使用RabbitMQ队列将数据发送到另一个系统(Symfony 3.4,Symfony 3.4,eNQUEU/ENQUEUE-BUNDLE 0.9)。 数据用于创建实体(存储在MySQL 8数据库中),该实体在事务中执行的情况下在未能发生的情况下执行,以将数据库返回到初始状态。
我的代码是这样的(在Symfony 3.4侧面错误是):在
function runInsideTx(callable $fn)
{
$this->em->getConnection()->beginTransaction();
try {
$resp = $fn();
$this->em->flush();
$this->em->getConnection()->commit();
return $resp;
} catch (Exception $ex) {
$this->em->getConnection()->rollBack();
throw $ex;
}
}
RuninSidetx INFER RUNINSIDETX INFER INFER INES INDES INSERES INSERING INDER
$this->functions->runInsideTx(function () use ($message) {
$entity = new SomeEntity();
...
$this->em->persist($entity);
$this->em->flush();
})
:2006 MySQL Server使用supportor:
[program:interop-manager_tasks-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /app/bin/console enqueue:transport:consume manager_tasks_processor manager_tasks_prod --message-limit=1 -vvv
autostart=true
autorestart=true
numprocs=2
redirect_stderr=true
stopwaitsecs=3600
stdout_logfile = /var/log/manager_tasks_worker_out.log
stderr_logfile = /var/log/manager_tasks_worker_err.log
user=application
environment=HOME="/home/application",USER="application"
随机常规错误:2006 mysql Server消失了<< /代码>发生。最初,我有一个MySQL 5数据库,并将其更改为MySQL 8,我在带有单个数据库的Docker容器中运行。
更新 我也有这个错误: 警告:发送查询数据包时<代码>错误。 有时会发生这种情况。它可能是它将任务发送到队列三次,并且
在运行MySQL Server时还添加了以下参数:
command: --sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' --default-authentication-plugin=mysql_native_password --max-allowed-packet=1G --innodb_buffer_pool_size=512M --innodb_lock_wait_timeout=500
但问题仍然存在。
显示诸如'%timeout%'
之类的变量
+-----------------------------------+----------+
| Variable_name | Value |
+-----------------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 500 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| mysqlx_connect_timeout | 30 |
| mysqlx_idle_worker_thread_timeout | 60 |
| mysqlx_interactive_timeout | 28800 |
| mysqlx_port_open_timeout | 0 |
| mysqlx_read_timeout | 30 |
| mysqlx_wait_timeout | 28800 |
| mysqlx_write_timeout | 60 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| replica_net_timeout | 60 |
| rpl_stop_replica_timeout | 31536000 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 28800 |
+-----------------------------------+----------+
I have one system (Symfony 5, symfony/messenger) sending data to another (Symfony 3.4, enqueue/enqueue-bundle 0.9) using a rabbitmq queue.
The data is used to create entities (stored in a MySql 8 database) that are executed within a transaction in case of a failure, to return the Database to the initial state.
My code is something like this (on the Symfony 3.4 side where the error is):
function runInsideTx(callable $fn)
{
$this->em->getConnection()->beginTransaction();
try {
$resp = $fn();
$this->em->flush();
$this->em->getConnection()->commit();
return $resp;
} catch (Exception $ex) {
$this->em->getConnection()->rollBack();
throw $ex;
}
}
And inside runInsideTx I have code like
$this->functions->runInsideTx(function () use ($message) {
$entity = new SomeEntity();
...
$this->em->persist($entity);
$this->em->flush();
})
Workers run inside a Docker container using supervisor:
[program:interop-manager_tasks-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /app/bin/console enqueue:transport:consume manager_tasks_processor manager_tasks_prod --message-limit=1 -vvv
autostart=true
autorestart=true
numprocs=2
redirect_stderr=true
stopwaitsecs=3600
stdout_logfile = /var/log/manager_tasks_worker_out.log
stderr_logfile = /var/log/manager_tasks_worker_err.log
user=application
environment=HOME="/home/application",USER="application"
Randomly the error General error: 2006 MySQL server has gone away
occurs. Initially I had a MySql 5 Database and changed it to a MySql 8, which I am running inside a docker container with a single database.
Update
I have this error too:
Warning: Error while sending QUERY packet.
This happens sometimes. It could be that it sends the task to the queue three times and it fails the first two and the third it processes it without problems
I also added the following parameters when running the MySQl server:
command: --sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' --default-authentication-plugin=mysql_native_password --max-allowed-packet=1G --innodb_buffer_pool_size=512M --innodb_lock_wait_timeout=500
But the problem persists.
SHOW VARIABLES LIKE '%timeout%'
+-----------------------------------+----------+
| Variable_name | Value |
+-----------------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 500 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| mysqlx_connect_timeout | 30 |
| mysqlx_idle_worker_thread_timeout | 60 |
| mysqlx_interactive_timeout | 28800 |
| mysqlx_port_open_timeout | 0 |
| mysqlx_read_timeout | 30 |
| mysqlx_wait_timeout | 28800 |
| mysqlx_write_timeout | 60 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| replica_net_timeout | 60 |
| rpl_stop_replica_timeout | 31536000 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 28800 |
+-----------------------------------+----------+
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论