From cd7fc15e68ff8db4c9028401083cf05e62d0c1a2 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Tue, 10 Oct 2023 10:29:13 +0200 Subject: [PATCH] Revert "Bug 1851253 - store new failure lines in database for persistent storage across reboots. (#7818)" This reverts commit 1310f34128061954f511a0c61cee3f0529e7c009. --- initialize_data.sh | 2 -- tests/test_setup.py | 8 +------- treeherder/config/settings.py | 4 ---- treeherder/model/error_summary.py | 8 +++----- treeherder/webapp/api/note.py | 7 +++---- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/initialize_data.sh b/initialize_data.sh index c41532ae674..61788ede6b7 100755 --- a/initialize_data.sh +++ b/initialize_data.sh @@ -12,6 +12,4 @@ if [ "${DATABASE_URL}" == "mysql://root@mysql/treeherder" ] || ./manage.py load_initial_data fi -./manage.py createcachetable - exec "$@" \ No newline at end of file diff --git a/tests/test_setup.py b/tests/test_setup.py index ae5bcb96050..2198ae7bb90 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -1,7 +1,7 @@ import pytest import responses from celery import current_app -from django.core.cache import caches +from django.core.cache import cache from django.core.management import call_command from treeherder.utils.http import fetch_text @@ -26,18 +26,12 @@ def test_no_missing_migrations(): call_command('makemigrations', interactive=False, dry_run=True, check_changes=True) -@pytest.mark.django_db def test_django_cache(): """Test the Django cache backend & associated server are properly set up.""" k, v = 'my_key', 'my_value' - cache = caches['default'] cache.set(k, v, 10) assert cache.get(k) == v - db_cache = caches['db_cache'] - db_cache.set(k, v, 10) - assert db_cache.get(k) == v - @current_app.task def add(x, y): diff --git a/treeherder/config/settings.py b/treeherder/config/settings.py index 07208352c0f..a9cd3481b2f 100644 --- a/treeherder/config/settings.py +++ b/treeherder/config/settings.py @@ -182,10 +182,6 @@ 'SOCKET_CONNECT_TIMEOUT': 5, }, }, - 'db_cache': { - "BACKEND": "django.core.cache.backends.db.DatabaseCache", - "LOCATION": "new_failure_cache", - }, } # Internationalization diff --git a/treeherder/model/error_summary.py b/treeherder/model/error_summary.py index b0192bdd26d..f2a1f8d9a78 100644 --- a/treeherder/model/error_summary.py +++ b/treeherder/model/error_summary.py @@ -3,7 +3,7 @@ import re import newrelic.agent -from django.core.cache import caches +from django.core.cache import cache from treeherder.model.models import Bugscache, TextLogError @@ -15,8 +15,6 @@ BUG_SUGGESTION_CACHE_TIMEOUT = 86400 LINE_CACHE_TIMEOUT_DAYS = 21 LINE_CACHE_TIMEOUT = 86400 * LINE_CACHE_TIMEOUT_DAYS -db_cache = caches['db_cache'] -cache = caches['default'] LEAK_RE = re.compile(r'\d+ bytes leaked \((.+)\)$|leak at (.+)$') CRASH_RE = re.compile(r'.+ application crashed \[@ (.+)\] \|.+') @@ -43,7 +41,7 @@ def get_error_summary(job, queryset=None): line_cache_key = 'mc_error_lines' if job.repository == "comm-central": line_cache_key = 'cc_error_lines' - line_cache = db_cache.get(line_cache_key) + line_cache = cache.get(line_cache_key) if line_cache is None: line_cache = {str(job.submit_time.date()): {}} else: @@ -85,7 +83,7 @@ def get_error_summary(job, queryset=None): logger.error('error caching error_summary for job %s: %s', job.id, e, exc_info=True) try: - db_cache.set(line_cache_key, line_cache, LINE_CACHE_TIMEOUT) + cache.set(line_cache_key, line_cache, LINE_CACHE_TIMEOUT) except Exception as e: newrelic.agent.record_custom_event('error caching error_lines for job', job.id) logger.error('error caching error_lines for job %s: %s', job.id, e, exc_info=True) diff --git a/treeherder/webapp/api/note.py b/treeherder/webapp/api/note.py index f347f4d37e1..53242bb29f2 100644 --- a/treeherder/webapp/api/note.py +++ b/treeherder/webapp/api/note.py @@ -1,4 +1,4 @@ -from django.core.cache import caches +from django.core.cache import cache from rest_framework import viewsets from rest_framework.decorators import action @@ -92,9 +92,8 @@ def create(self, request, project): if fc_id == 2: # this is for fixed_by_commit (backout | follow_up_commit) # remove cached failure line counts - db_cache = caches['db_cache'] line_cache_key = 'error_lines' - line_cache = db_cache.get(line_cache_key) + line_cache = cache.get(line_cache_key) date = current_job.submit_time.date().isoformat() if line_cache and date in line_cache.keys(): for err in TextLogError.objects.filter(job=current_job): @@ -108,7 +107,7 @@ def create(self, request, project): ): del line_cache[date]["new_lines"][cache_clean_line] try: - db_cache.set(line_cache_key, line_cache, LINE_CACHE_TIMEOUT) + cache.set(line_cache_key, line_cache, LINE_CACHE_TIMEOUT) except Exception as e: logger.error( 'error caching error_lines for job %s: %s',