Skip to content

Commit

Permalink
Add log message when discarding recording segments in cache (blakebla…
Browse files Browse the repository at this point in the history
…ckshear#3439)

* Add log message when discarding recording segments in cache

Currently Frigate silently discards recording segments in cache if there's more than "keep_count" for a camera, which can happen on high load/busy/slow systems.
This results in recording segments being lost with no apparent cause in the logs (even when set to debug).
This PR adds a warning log entry when discarding segments, in the same way as discarding corrupted segments

* Add explanatory warning and properly format cache_path warning

* lint fixes

Co-authored-by: Blake Blackshear <[email protected]>
  • Loading branch information
deviant77 and blakeblackshear committed Jul 19, 2022
1 parent dfbebb6 commit ed1897d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frigate/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ def move_files(self):
# delete all cached files past the most recent 5
keep_count = 5
for camera in grouped_recordings.keys():
if len(grouped_recordings[camera]) > keep_count:
segment_count = len(grouped_recordings[camera])
if segment_count > keep_count:
logger.warning(
f"Too many recording segments in cache for {camera}. Keeping the {keep_count} most recent segments out of {segment_count}, discarding the rest..."
)
to_remove = grouped_recordings[camera][:-keep_count]
for f in to_remove:
Path(f["cache_path"]).unlink(missing_ok=True)
self.end_time_cache.pop(f["cache_path"], None)
cache_path = f["cache_path"]
logger.warning(f"Discarding a recording segment: {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:]

for camera, recordings in grouped_recordings.items():
Expand Down

0 comments on commit ed1897d

Please sign in to comment.