New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法支持后端数据库的binlog主从同步 #1886

Closed
RaynorAZ opened this Issue Oct 9, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@RaynorAZ

RaynorAZ commented Oct 9, 2018

[简述你的问题]
后端数据库开启binlog之后,重启jumpserver时报
django.db.utils.OperationalError: (1665, 'Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.')

使用版本

[请提供你使用的Jumpserver版本 1.x.x 注: 0.3.x不再提供支持]
1.4.1

问题复现步骤
  1. [步骤1] 数据库配置my.cnf,开启binlog,重启数据库
  2. [步骤2] 重启jumpserver
具体表现[截图可能会更好些,最好能截全]

Traceback (most recent call last):
File "manage.py", line 28, in
execute_from_command_line(sys.argv)
File "/opt/py3/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/py3/lib/python3.6/site-packages/django/core/management/init.py", line 357, in execute
django.setup()
File "/opt/py3/lib/python3.6/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/py3/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/data0/jumpserver/jumpserver/apps/assets/apps.py", line 10, in ready
from . import signals_handler
File "/data0/jumpserver/jumpserver/apps/assets/signals_handler.py", line 9, in
from .tasks import update_assets_hardware_info_util,
File "/data0/jumpserver/jumpserver/apps/assets/tasks.py", line 124, in
@after_app_shutdown_clean
File "/data0/jumpserver/jumpserver/apps/ops/celery/utils.py", line 150, in decorate
'enabled': True,
File "/data0/jumpserver/jumpserver/apps/ops/celery/utils.py", line 111, in create_or_update_celery_periodic_tasks
defaults=defaults, name=name,
File "/opt/py3/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/managers.py", line 16, in update_or_create
self._update_model_with_dict(obj, dict(defaults or {}, **kwargs))
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/managers.py", line 22, in _update_model_with_dict
obj.save()
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/models.py", line 316, in save
super(PeriodicTask, self).save(*args, **kwargs)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 717, in save
force_update=force_update, update_fields=update_fields)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 742, in save_base
update_fields=update_fields,
File "/opt/py3/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "/opt/py3/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in
for receiver in self._live_receivers(sender)
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/models.py", line 217, in changed
cls.update_changed()
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/models.py", line 221, in update_changed
cls.objects.update_or_create(ident=1, defaults={'last_update': now()})
File "/opt/py3/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/managers.py", line 16, in update_or_create
self._update_model_with_dict(obj, dict(defaults or {}, **kwargs))
File "/opt/py3/lib/python3.6/site-packages/django_celery_beat/managers.py", line 22, in _update_model_with_dict
obj.save()
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 717, in save
force_update=force_update, update_fields=update_fields)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 747, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 811, in _save_table
forced_update)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/base.py", line 860, in _do_update
return filtered._update(values) > 0
File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 709, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1379, in execute_sql
cursor = super().execute_sql(result_type)
File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
cursor.execute(sql, params)
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/opt/py3/lib/python3.6/site-packages/django/db/utils.py", line 89, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/opt/py3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/opt/py3/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1665, 'Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.')

  • Start Celery as Distributed Task Queue

  • Start Beat as Periodic Task Scheduler

其他

[注:] 完成后请关闭 issue

@ibuler

This comment has been minimized.

Show comment
Hide comment
@ibuler

ibuler Oct 12, 2018

Member

binlog_format=MIXED 使用statement需要修改隔离级别

Member

ibuler commented Oct 12, 2018

binlog_format=MIXED 使用statement需要修改隔离级别

@ibuler ibuler closed this Oct 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment