moonfire-nvr/db
Scott Lamb c271cfa2b5 make Writer enforce maximum recording duration
My installation recently somehow ended up with a recording with a
duration of 503793844 90,000ths of a second, way over the maximum of 5
minutes. (Looks like the machine was pretty unresponsive at the time
and/or having network problems.)

When this happens, the system really spirals. Every flush afterward (12
per minute with my installation) fails with a CHECK constraint failure
on the recording table. It never gives up on that recording. /var/log
fills pretty quickly as this failure is extremely verbose (a stack
trace, and a line for each byte of video_index). Eventually the sample
file dirs fill up too as it continues writing video samples while GC is
stuck. The video samples are useless anyway; given that they're not
referenced in the database, they'll be deleted on next startup.

This ensures the offending recording is never added to the database, so
we don't get the same persistent problem. Instead, writing to the
recording will fail. The stream will drop and be retried. If the
underlying condition that caused a too-long recording (many
non-key-frames, or the camera returning a crazy duration, or the
monotonic clock jumping forward extremely, or something) has gone away,
the system should recover.
2019-01-29 08:26:36 -08:00
..
testdata initial split of database to a separate crate 2018-02-20 23:15:39 -08:00
upgrade lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
auth.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
Cargo.toml backend support for live stream (#59) 2019-01-21 15:58:52 -08:00
check.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
coding.rs initial split of database to a separate crate 2018-02-20 23:15:39 -08:00
db.rs backend support for live stream (#59) 2019-01-21 15:58:52 -08:00
dir.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
lib.rs lose "extern crate" everywhere (Rust 2018 edition) 2018-12-28 21:59:39 -06:00
raw.rs properly test fix for #64 2019-01-04 16:11:58 -08:00
recording.rs make Writer enforce maximum recording duration 2019-01-29 08:26:36 -08:00
schema.proto update design docs for new-schema branch changes 2018-03-24 20:51:30 -07:00
schema.rs upgrade a few deps 2018-08-24 22:06:14 -07:00
schema.sql preliminary web support for auth (#26) 2018-11-27 11:08:33 -08:00
testutil.rs properly test fix for #64 2019-01-04 16:11:58 -08:00
writer.rs make Writer enforce maximum recording duration 2019-01-29 08:26:36 -08:00