From 63f033c30c691a76483e1f9f9b686f29c7a3f4c3 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Wed, 20 Nov 2024 11:37:28 -0800 Subject: [PATCH] Add signal handler that runs postgres setting on connection created --- contentcuration/contentcuration/apps.py | 3 +++ contentcuration/contentcuration/signals.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 contentcuration/contentcuration/signals.py diff --git a/contentcuration/contentcuration/apps.py b/contentcuration/contentcuration/apps.py index 6d0fa858ff..2466492feb 100644 --- a/contentcuration/contentcuration/apps.py +++ b/contentcuration/contentcuration/apps.py @@ -8,6 +8,9 @@ class ContentConfig(AppConfig): name = 'contentcuration' def ready(self): + # Import signals + import contentcuration.signals # noqa + if settings.AWS_AUTO_CREATE_BUCKET and not is_gcs_backend(): from contentcuration.utils.minio_utils import ensure_storage_bucket_public ensure_storage_bucket_public() diff --git a/contentcuration/contentcuration/signals.py b/contentcuration/contentcuration/signals.py new file mode 100644 index 0000000000..5774253fab --- /dev/null +++ b/contentcuration/contentcuration/signals.py @@ -0,0 +1,14 @@ +from django.db.backends.signals import connection_created +from django.dispatch import receiver + + +@receiver(connection_created) +def set_jit(sender, connection, **kwargs): + """ + Disable Just-In-Time compilation for PostgreSQL databases, at least until we can + optimize its use. + https://www.postgresql.org/docs/12/runtime-config-query.html#GUC-JIT + """ + if connection.vendor == 'postgresql': + with connection.cursor() as cursor: + cursor.execute("SET jit = 'off';")