【问题标题】:Does YugabyteDB support Django even though the SAVEPOINTS feature is not yet supported?即使尚不支持 SAVEPOINTS 功能,YugabyteDB 是否支持 Django?
【发布时间】:2021-09-21 12:14:39
【问题描述】:

有一个 Django 应用程序设置来与 YugabyteDB 通信,但是在运行迁移时我们遇到了以下错误:

Traceback (most recent call last):
  File "/opt/env/lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 54, in get_for_model
    ct = self.get(app_label=opts.app_label, model=opts.model_name)
  File "/opt/env/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/env/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
__fake__.DoesNotExist: ContentType matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/env/lib/python3.6/site-packages/django/db/models/query.py", line 464, in get_or_create
    return self.get(**lookup), False
  File "/opt/env/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
__fake__.DoesNotExist: ContentType matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/env/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/opt/env/lib/python3.6/site-packages/django_prometheus/db/common.py", line 63, in execute
    return super(CursorWrapper, self).execute(*args, **kwargs)
psycopg2.errors.FeatureNotSupported: SAVEPOINT <transaction> not supported yet
LINE 1: SAVEPOINT "s140500455238528_x1"
        ^
HINT:  See https://github.com/YugaByte/yugabyte-db/issues/1125. Click '+' on the description to raise its priority

由于 YugabyteDB 今天似乎不支持 SAVEPOINTS,我们如何解决这个 Django 错误?

[免责声明:这个问题最初是由 YugabyteDB 用户通过电子邮件提出的]

【问题讨论】:

    标签: django yugabyte-db


    【解决方案1】:

    YugabyteDB 将在新版本中支持Savepoint feature。所以可能看不到这个问题。

    但是,我们已经建立了一个Django backend for YugabyteDB。它确保了 YugabyteDB 与 Django 的兼容性。在较新的版本进入生产环境之前,我们已经禁用了后端的保存点支持,即后端告诉 Django 它不支持保存点(uses_savepoints = False),因此 Django 不会自动使用保存点,这个异常不应该是见过。但是,最外层事务的原子性还是有保证的。

    此外,不应明确使用保存点 API,因为它将是无操作的,除非您使用的是支持保存点的 YB 版本。

    【讨论】:

      猜你喜欢
      • 2022-10-17
      • 2018-09-21
      • 2013-09-16
      • 1970-01-01
      • 2013-09-25
      • 2015-11-13
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      相关资源
      最近更新 更多