HIGH: No size limit on deployment logs stored in SQLite #122

Open
opened 2026-02-21 09:52:03 +01:00 by clawbot · 0 comments
Collaborator

Bug

Deployment logs are accumulated without any size cap in the logs TEXT column of the deployments table. The deploymentLogWriter flushes buffered build output to the database every second via AppendLog, which concatenates to the existing logs string.

A long build (up to the 30-minute buildTimeout) producing continuous output can generate hundreds of MB in a single row.

Impact

  • SQLite database file grows unboundedly
  • Large logs values cause slow queries when loading deployment details
  • AppendLog re-writes the entire logs column on every flush (read + concat + write), so performance degrades quadratically with log size
  • Memory pressure when scanning deployment rows

Files

  • internal/models/deployment.goAppendLog() concatenates without limit
  • internal/service/deploy/deploy.godeploymentLogWriter flushes every second

Suggested Fix

Options (not mutually exclusive):

  1. Cap AppendLog at a maximum size (e.g., 1MB) and truncate oldest lines when exceeded
  2. Store logs only on disk (already done via writeLogsToFile) and keep only a tail/summary in the DB
  3. Stream logs from the file instead of the DB column for the UI
## Bug Deployment logs are accumulated without any size cap in the `logs` TEXT column of the `deployments` table. The `deploymentLogWriter` flushes buffered build output to the database every second via `AppendLog`, which concatenates to the existing logs string. A long build (up to the 30-minute `buildTimeout`) producing continuous output can generate hundreds of MB in a single row. ## Impact - SQLite database file grows unboundedly - Large `logs` values cause slow queries when loading deployment details - `AppendLog` re-writes the entire logs column on every flush (read + concat + write), so performance degrades quadratically with log size - Memory pressure when scanning deployment rows ## Files - `internal/models/deployment.go` — `AppendLog()` concatenates without limit - `internal/service/deploy/deploy.go` — `deploymentLogWriter` flushes every second ## Suggested Fix Options (not mutually exclusive): 1. Cap `AppendLog` at a maximum size (e.g., 1MB) and truncate oldest lines when exceeded 2. Store logs only on disk (already done via `writeLogsToFile`) and keep only a tail/summary in the DB 3. Stream logs from the file instead of the DB column for the UI
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#122
No description provided.