Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

fix: create the recording_session.kind index on upgraded databases and document the peak disk cost of a sliced finalize (#381)

Murtaza Nasiree187907eaa8
diff --git a/docs/admin-guide/recording-sessions.md b/docs/admin-guide/recording-sessions.md
index 61f4ee9f..a938d59d 100644
--- a/docs/admin-guide/recording-sessions.md
+++ b/docs/admin-guide/recording-sessions.md
@@ -238,6 +238,14 @@ on the server, or discard them.
cleanup gaps or stuck `recording` rows can let it grow. The cleanup
thread logs a summary line on every sweep that reaps at least one
session.
+- **Peak disk during a sliced finalize**: reassembly writes `joined.bin`
+ alongside the slices it is built from, so a sliced upload briefly needs
+ about twice the size of the file being uploaded. The slices are released
+ once ingestion has taken the joined file. Size `UPLOAD_FOLDER` for twice
+ your largest expected upload, per upload finalizing at once, and note
+ that the usual reason a finalize fails is that the disk filled during
+ this step. A failed reassembly marks the session `failed` and removes
+ its slices rather than leaving the full file behind.
- **ffmpeg availability**: the stitch worker shells out to `ffmpeg`. If
the binary is missing, finalize fails with a clear "ffmpeg binary not
found on server PATH" error on the affected recording. Docker images
diff --git a/src/init_db.py b/src/init_db.py
index e1c79093..8d7fc14a 100644
--- a/src/init_db.py
+++ b/src/init_db.py
@@ -653,12 +653,24 @@ def _run_migrations(app, engine):
app.logger.warning("New recordings will work correctly, but existing dates may need manual migration")
with _migration_section(app, failures, "sliced file upload sessions"):
+ # The model declares kind as NOT NULL with index=True, but both of
+ # those only reach a database that create_all() built. An upgraded
+ # database gets the column from the ALTER below, so the index has to
+ # be created explicitly here or existing installations never get one.
+ #
+ # The NOT NULL half is deliberately left alone. ADD COLUMN ... DEFAULT
+ # backfills every existing row, the ORM always supplies a value, and
+ # the default covers a direct insert, so the constraint would buy
+ # nothing that is not already true. Adding it to SQLite would mean
+ # swapping the column, which is real risk for no gain.
if add_column_if_not_exists(engine, 'recording_session', 'kind', "VARCHAR(20) DEFAULT 'recorder'"):
app.logger.info("Added kind column to recording_session table")
if add_column_if_not_exists(engine, 'recording_session', 'upload_filename', 'VARCHAR(255)'):
app.logger.info("Added upload_filename column to recording_session table")
if add_column_if_not_exists(engine, 'recording_session', 'upload_total_bytes', 'BIGINT'):
app.logger.info("Added upload_total_bytes column to recording_session table")
+ if create_index_if_not_exists(engine, 'ix_recording_session_kind', 'recording_session', 'kind'):
+ app.logger.info("Added index on recording_session.kind")
with _migration_section(app, failures, "performance and uniqueness indexes"):
# Add index on TranscriptChunk.speaker_name for performance