Skip to content

Clearing out expired ObjectChanges can cause HTTP worker memory consumption to balloon #6056

@mpalmer

Description

@mpalmer

NetBox version

v2.10.6

Python version

3.8

Steps to Reproduce

  1. Use Netbox as normal.
  2. Make a significant number of changing requests.
  3. At some random time (with 0.1% probability) this line of code will be executed:
    ObjectChange.objects.filter(time__lt=cutoff).delete()
  4. If there are a lot of objects whose time is before the cutoff, then the memory required to load all those objects before deleting them will cause the HTTP worker process to use a lot of memory, potentially causing all manner of unpleasantness.

Expected Behavior

Preferably, log trimming would be moved out of the HTTP service path altogether, because running a potentially expensive query (only sometimes) when you're trying to respond quickly to HTTP requests is a great way to make your p99 stats look really bad. At the very least, though, the query needs to be a straight-up DELETE FROM ... WHERE ..., rather than a load-then-delete.

Observed Behavior

Much memory. Very OOM.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions