-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: Create logic for automatically cleaning up dead streams (#2013)
* api: Create API for clean-up actually inactive streams * api: Move the filtering logic out of activeCleanup * api: Fix the active cleanup query - We were missing the parentId check so it was reading way more streams than necessary (all child streams/sessions). - There are A LOT of forgotten streams in our DB (400k parents), so we need to put some limit on this query * api: Avoid using all DB resources for cleanup * api: Fix tests (they were broken before!) * Revert "api: Avoid using all DB resources for cleanup" This reverts commit aff5120. * api: Create separate DB conn pool for bg jobs Use it on: - Webhooks queue handler - Tasks queue handler - Usage billing job - (new) Active cleanup job * api: Fix tests * api: Stop triggering isActive clean-up from GETs Still monkey-patch responses to keep the same UX, but the actual recordings processing will only be triggered once the active clean-up job is triggered. * api: Add tests for cleanup job * api: Change default limit to 1000 It's a bit too expensive to do 10000 at once * api: Fix override of isActive (breaking tests) * api/stream: Clean-up lost sessions as well as parents Turns out there are also children lost from their parents out there, so we have to list them all. * api/cannon: Make sure we clear unused sessions/streams objects * api/cannon: Fix typing of handleRecordingWaitingChecks * api: Make sure we always clear all isActive fields * api/stream: Fix clean-up streams filtering logic * .github: Create cronjob to clean-up inactive streams * api: Clear streams that already have assets generated * api/stream: Remove ordering from list query Just makes things super slow and is not useful * api/stream: Clean all child streams from same sess at once * api/stream: Make size of clean-up more predictable Don't filter on the outer level, but rather make sure the pipeline supports an array of child streams. * api/stream: Remove test for deduping by sessionId Now we clean all of them, but we merge before the cleanup processing only the session once. No easy way to catch that on tests. * api/stream: Stop using lodash * api/stream: Run clean-up synchronously on API Also parallelize parent streams * api/stream: Default streamId to empty str * api/stream: Parallelize child stream processing * api/stream: Only use isActive field from streams There are some bugged sessions that got isActive set to them * Revert "api/stream: Only use isActive field from streams" This reverts commit 8621089. It was a staging only thing, likely from a development version. * api/stream: Fallback to createdAt if lastSeen never set * api/stream: Remove monkey-patching of stream objects 😍 * [DEV] Increase log level to debug in staging * api/stream: Only trigger recording processing when stream goes offline * api/stream: Check child streams shouldCleanupIsActive as well
- Loading branch information
Showing
23 changed files
with
469 additions
and
201 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.