Skip to content

Commit

Permalink
Don't allow unlimited unprocessed frames to stay in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Oct 14, 2024
1 parent 72aa68c commit 4034980
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions frigate/record/maintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ async def move_files(self) -> None:
)
)
)

# see if the recording mover is too slow and segments need to be deleted
if processed_segment_count > keep_count:
logger.warning(
f"Unable to keep up with recording segments in cache for {camera}. Keeping the {keep_count} most recent segments out of {processed_segment_count} and discarding the rest..."
Expand All @@ -153,6 +155,22 @@ async def move_files(self) -> None:
self.end_time_cache.pop(cache_path, None)
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]

# see if detection has failed and unprocessed segments need to be deleted
unprocessed_segment_count = (
len(grouped_recordings[camera]) - processed_segment_count
)
if unprocessed_segment_count > keep_count:
logger.warning(
f"Too many unprocessed recording segments in cache for {camera}. This likely indicates an issue with the detect stream, keeping the {keep_count} most recent segments out of {unprocessed_segment_count} and discarding the rest..."
)
to_remove = grouped_recordings[camera][:-keep_count]
for rec in to_remove:
cache_path = rec["cache_path"]
Path(cache_path).unlink(missing_ok=True)
self.end_time_cache.pop(cache_path, None)
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]


tasks = []
for camera, recordings in grouped_recordings.items():
# clear out all the object recording info for old frames
Expand Down

0 comments on commit 4034980

Please sign in to comment.