From cd9867081d1afc5a3a913b976c9998fa6a8611fc Mon Sep 17 00:00:00 2001
From: Vermaas <vermaas@astron.nl>
Date: Tue, 22 Aug 2023 11:46:00 +0200
Subject: [PATCH] switch off silk (it causes db deadlocks under high load)

---
 atdb/atdb/settings/base.py                       |  8 ++++----
 atdb/atdb/urls.py                                |  2 +-
 atdb/requirements/base.txt                       |  2 +-
 .../templates/taskdatabase/index.html            |  2 +-
 atdb/taskdatabase/views.py                       | 16 ++++++++--------
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/atdb/atdb/settings/base.py b/atdb/atdb/settings/base.py
index 8c2f774f..376c991a 100644
--- a/atdb/atdb/settings/base.py
+++ b/atdb/atdb/settings/base.py
@@ -37,7 +37,7 @@ INSTALLED_APPS = [
     'django_tables2',
     'bootstrap3',
     'fontawesome_free',
-    'silk',
+    #'silk',
 
     ## These are required for ASTRONauth
     'django.contrib.sites',
@@ -59,7 +59,7 @@ MIDDLEWARE = [
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
-    'silk.middleware.SilkyMiddleware',
+    #'silk.middleware.SilkyMiddleware',
 ]
 
 ROOT_URLCONF = 'atdb.urls'
@@ -253,5 +253,5 @@ logger.info("KEYCLOAK_URL:" + KEYCLOAK_URL)
 SESSION_COOKIE_NAME = 'atdb_session_id'
 CSRF_COOKIE_NAME = 'atdb_csrftoken'
 
-SILKY_PYTHON_PROFILER = False
-SILKY_PYTHON_PROFILER_BINARY = False
\ No newline at end of file
+#SILKY_PYTHON_PROFILER = False
+#SILKY_PYTHON_PROFILER_BINARY = False
\ No newline at end of file
diff --git a/atdb/atdb/urls.py b/atdb/atdb/urls.py
index 5b812092..b1e670ff 100644
--- a/atdb/atdb/urls.py
+++ b/atdb/atdb/urls.py
@@ -7,5 +7,5 @@ urlpatterns = [
     path('atdb/admin/', admin.site.urls),
     path('atdb/api-auth/', include('rest_framework.urls')),
     path("atdb/astronauth/", include("astronauth.urls")),  # include astronauth
-    path('atdb/silk/', include('silk.urls', namespace='silk'))
+    #path('atdb/silk/', include('silk.urls', namespace='silk'))
 ]
diff --git a/atdb/requirements/base.txt b/atdb/requirements/base.txt
index c268dc8f..694d6390 100644
--- a/atdb/requirements/base.txt
+++ b/atdb/requirements/base.txt
@@ -6,7 +6,7 @@ django-bootstrap3==14.2.0
 django-cors-headers==3.6.0
 django-extensions==3.1.0
 django-filter==2.3.0
-django-silk==5.0.3
+#django-silk==5.0.3
 django-tables2==2.3.4
 djangorestframework==3.12.2
 fontawesome-free==5.15.2
diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html
index 86ad7df0..0c25d8e8 100644
--- a/atdb/taskdatabase/templates/taskdatabase/index.html
+++ b/atdb/taskdatabase/templates/taskdatabase/index.html
@@ -31,7 +31,7 @@
             {% include 'taskdatabase/pagination.html' %}
         </div>
     </div>
-    <p class="footer"> Version 21 Aug 2023
+    <p class="footer"> Version 22 Aug 2023
 </div>
 
 {% include 'taskdatabase/refresh.html' %}
diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py
index f6c8ea3d..535a8ac4 100644
--- a/atdb/taskdatabase/views.py
+++ b/atdb/taskdatabase/views.py
@@ -17,7 +17,7 @@ from django_tables2.views import SingleTableMixin
 from django.shortcuts import render, redirect, reverse
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 from rest_framework.request import Request
-from silk.profiling.profiler import silk_profile
+#from silk.profiling.profiler import silk_profile
 
 from django.conf import settings
 from .models import Task, Workflow, LogEntry, Configuration, Job, PostProcessingRule, Monitor, LatestMonitor, State
@@ -213,7 +213,7 @@ class IndexView(ListView):
     # by default this returns the list in an object called object_list, so use 'object_list' in the html page.
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
-    @silk_profile(name='IndexView')
+    #@silk_profile(name='IndexView')
     def get_queryset(self):
 
         tasks = get_filtered_tasks(self.request)
@@ -290,7 +290,7 @@ class ShowQualityPage(ListView):
     # by default this returns the list in an object called object_list, so use 'object_list' in the html page.
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
-    @silk_profile(name='ShowQualityPage')
+    #@silk_profile(name='ShowQualityPage')
     def get_queryset(self):
 
         tasks = get_filtered_tasks(self.request)
@@ -332,7 +332,7 @@ class ShowValidationPage(ListView):
     # by default this returns the list in an object called object_list, so use 'object_list' in the html page.
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
-    @silk_profile(name='ShowValidationPage')
+    #@silk_profile(name='ShowValidationPage')
     def get_queryset(self):
         
         #stored_tasks = Task.objects.filter(status__icontains=State.STORED.value)
@@ -376,7 +376,7 @@ class ShowFailuresPage(ListView):
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
 
-    @silk_profile(name='ShowFailuresPage')
+    #@silk_profile(name='ShowFailuresPage')
     def get_queryset(self):
 
         #failed_tasks = Task.objects.filter(status__icontains=State.FAILED.value)
@@ -417,7 +417,7 @@ class ShowDiscardedPage(ListView):
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
 
-    @silk_profile(name='ShowDiscardedPage')
+    #@silk_profile(name='ShowDiscardedPage')
     def get_queryset(self):
 
         discarded_tasks = Task.objects.filter(status__icontains='discarded')
@@ -456,7 +456,7 @@ class ShowFinishedPage(ListView):
     # by default this returns the list in an object called object_list, so use 'object_list' in the html page.
     # but if 'context_object_name' is defined, then this returned list is named and can be accessed that way in html.
     context_object_name = 'my_tasks'
-    @silk_profile(name='ShowFinishedPage')
+    #@silk_profile(name='ShowFinishedPage')
     def get_queryset(self):
 
         ###archived_tasks = Task.objects.filter(status=State.FINISHED.value)
@@ -488,7 +488,7 @@ class ShowFinishedPage(ListView):
 
 
 # this provides a broad range of filters for the search_box in the GUI
-@silk_profile(name='get_filtered_tasks')
+#@silk_profile(name='get_filtered_tasks')
 def get_filtered_tasks(request, pre_filtered_tasks=None, distinct=None):
     filtered_tasks_as_list = None
 
-- 
GitLab