mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: persist boundary logs (#24812)
Add database persistence to `ReportBoundaryLogs`. On first log for a session, the handler lazy-creates a `boundary_sessions` row, then batch-inserts all `BoundaryLog` entries into `boundary_logs`. Structured logging and usage tracking are preserved. Old boundary clients (no `session_id`) fall back to log-only mode. > [!NOTE] > This PR was authored by Coder Agents.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
-- Delete orphaned logs that have no matching session before restoring
|
||||
-- the FK constraint.
|
||||
DELETE FROM boundary_logs bl
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM boundary_sessions bs WHERE bs.id = bl.session_id
|
||||
);
|
||||
|
||||
ALTER TABLE boundary_logs
|
||||
ADD CONSTRAINT boundary_logs_session_id_fkey
|
||||
FOREIGN KEY (session_id) REFERENCES boundary_sessions(id) ON DELETE CASCADE;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Drop the foreign key so that boundary logs can be inserted before
|
||||
-- the session row exists. The session is created lazily and may fail
|
||||
-- on transient errors; removing the FK lets logs persist regardless.
|
||||
-- The session row will be created on a subsequent batch, retroactively
|
||||
-- linking the orphaned logs via session_id.
|
||||
ALTER TABLE boundary_logs DROP CONSTRAINT boundary_logs_session_id_fkey;
|
||||
Reference in New Issue
Block a user