Remove content type lookup when clearing cached values #8508

Closed
opened 2025-12-29 20:37:34 +01:00 by adam · 1 comment
Owner

Originally created by @abhi1693 on GitHub (Aug 24, 2023).

Originally assigned to: @abhi1693 on GitHub.

Proposed Changes

index 9a29c54f5..e072c220a 100644
--- a/netbox/extras/management/commands/reindex.py
+++ b/netbox/extras/management/commands/reindex.py
@@ -69,10 +69,7 @@ class Command(BaseCommand):
         if not kwargs['lazy']:
             self.stdout.write('Clearing cached values... ', ending='')
             self.stdout.flush()
-            content_types = [
-                ContentType.objects.get_for_model(model) for model in indexers.keys()
-            ]
-            deleted_count = search_backend.clear(content_types)
+            deleted_count = search_backend.clear()
             self.stdout.write(f'{deleted_count} entries deleted.')

Justification

When trying to debug the issue for #13507, I wanted to clear my existing cache so I ran ./manage.py reindex expecting all values to be removed including any plugins that have been uninstalled. However, that was not the case and my search was still broken as the plugin values still existed within CacheValue

Originally created by @abhi1693 on GitHub (Aug 24, 2023). Originally assigned to: @abhi1693 on GitHub. ### Proposed Changes ```patch index 9a29c54f5..e072c220a 100644 --- a/netbox/extras/management/commands/reindex.py +++ b/netbox/extras/management/commands/reindex.py @@ -69,10 +69,7 @@ class Command(BaseCommand): if not kwargs['lazy']: self.stdout.write('Clearing cached values... ', ending='') self.stdout.flush() - content_types = [ - ContentType.objects.get_for_model(model) for model in indexers.keys() - ] - deleted_count = search_backend.clear(content_types) + deleted_count = search_backend.clear() self.stdout.write(f'{deleted_count} entries deleted.') ``` ### Justification When trying to debug the issue for #13507, I wanted to clear my existing cache so I ran `./manage.py reindex` expecting all values to be removed including any plugins that have been uninstalled. However, that was not the case and my search was still broken as the plugin values still existed within `CacheValue`
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:37:34 +01:00
adam closed this issue 2025-12-29 20:37:34 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 24, 2023):

I'm going to classify this as a bug since we're altering the command's (undesired) behavior.

@jeremystretch commented on GitHub (Aug 24, 2023): I'm going to classify this as a bug since we're altering the command's (undesired) behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8508