fix: prevent undesired timelines reaching TSR#1627
fix: prevent undesired timelines reaching TSR#1627ianshade wants to merge 3 commits intoSofie-Automation:mainfrom
Conversation
prevents from submitting an incorrect timeline before the model is ready to be saved (if `updateTimeline` is not the last thing before saving, something might still throw, leading to disposal of the model); makes sure it runs after deferBeforeSave callback, as they might need to run before submitting the timeline (e.g. in order for onRundownActivate to complete device preparation before the rundown baseline reaches TSR)
…ing the timeline moves timeline generation to `saveAllToDatabase`
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
nytamin
left a comment
There was a problem hiding this comment.
Sounds like a reasonable change to me.
Should we update the documentation of onRundownActivate / onRundownDeactivate to claify their capabilities while we're at it?
| // Generate timeline if needed | ||
| if (this.#timelineNeedsRegeneration) { | ||
| await this.#regenerateStudioTimeline() | ||
| this.#timelineNeedsRegeneration = false |
There was a problem hiding this comment.
Should this.#timelineNeedsRegeneration = false be moved into this.#regenerateStudioTimeline()?
Since this.#regenerateStudioTimeline() is async, this.#timelineNeedsRegeneration = false should be done in the beginning of that method, I think.
There was a problem hiding this comment.
I dont think it really makes a difference, as this is inside saveAllToDatabase which if anything else tries to modify the StudioPlayoutModel at the same time will be a race condition
About the Contributor
This pull request is posted on behalf of TV 2 Norge.
Type of Contribution
This is a:
Bug fix
Current Behavior
Timeline might be saved and fast-tracked to TSR (Playout Gateway) before it is certain that the result of the playout job will be committed.
Moreover, it happens before
onRundownActivate/onRundownDeactivatecallbacks run. Consequence is twofold:New Behavior
This pull request refactors and improves how and when timeline updates are triggered, generated, and published for both playlists and studios in the playout worker. The key change is to decouple timeline generation from immediate execution, instead marking that a timeline update is needed and regenerating timelines just before saving the model - when it is definitely correct and safe to do so. The operations are ordered so that lenghty execution of the callbacks does not contribute to the latency measured between timeline generation and its resolution in TSR.
Testing
Affected areas
Playout logic - generating, fast-tracking and saving the timeline
Time Frame
Other Information
Status