Skip to content

Commit cc43338

Browse files
committed
Fixes #6056: Optimize change log cleanup
1 parent 1fba4b7 commit cc43338

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

docs/release-notes/version-2.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Bug Fixes
66

77
* [#5419](https://github.com/netbox-community/netbox/issues/5419) - Update parent device/VM when deleting a primary IP
8+
* [#6056](https://github.com/netbox-community/netbox/issues/6056) - Optimize change log cleanup
89
* [#6144](https://github.com/netbox-community/netbox/issues/6144) - Fix MAC address field display in VM interfaces search form
910
* [#6152](https://github.com/netbox-community/netbox/issues/6152) - Fix custom field filtering for cables, virtual chassis
1011

netbox/extras/signals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from cacheops.signals import cache_invalidated, cache_read
55
from django.conf import settings
66
from django.contrib.contenttypes.models import ContentType
7+
from django.db import DEFAULT_DB_ALIAS
78
from django.db.models.signals import m2m_changed, pre_delete
89
from django.utils import timezone
910
from django_prometheus.models import model_deletes, model_inserts, model_updates
@@ -52,7 +53,7 @@ def _handle_changed_object(request, sender, instance, **kwargs):
5253
# Housekeeping: 0.1% chance of clearing out expired ObjectChanges
5354
if settings.CHANGELOG_RETENTION and random.randint(1, 1000) == 1:
5455
cutoff = timezone.now() - timedelta(days=settings.CHANGELOG_RETENTION)
55-
ObjectChange.objects.filter(time__lt=cutoff).delete()
56+
ObjectChange.objects.filter(time__lt=cutoff)._raw_delete(using=DEFAULT_DB_ALIAS)
5657

5758

5859
def _handle_deleted_object(request, sender, instance, **kwargs):

0 commit comments

Comments
 (0)