Skip to content

Commit 93f4b9d

Browse files
committed
chore: doc and logging for troubleshooting
1 parent bdab8c4 commit 93f4b9d

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

packages/corelib/src/dataModel/Segment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SegmentNote } from './Notes'
55
export enum SegmentOrphanedReason {
66
/** Segment is deleted from the NRCS but we still need it */
77
DELETED = 'deleted',
8-
/** Segment should be hidden, but it is still playing */
8+
/** Blueprints want the Segment to be hidden, but it is still playing so is must not be hidden right now. */
99
HIDDEN = 'hidden',
1010
/** Segment is owned by playout, and is for AdlibTesting in its rundown */
1111
ADLIB_TESTING = 'adlib-testing',

packages/job-worker/src/ingest/commit.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ export async function CommitIngestOperation(
178178
// Ensure any adlibbed parts are updated to follow the segmentId of the previous part
179179
await updateSegmentIdsForAdlibbedPartInstances(context, ingestModel, beforePartMap)
180180

181+
if (data.renamedSegments && data.renamedSegments.size > 0) {
182+
logger.debug(`Renamed segments: ${JSON.stringify(Array.from(data.renamedSegments.entries()))}`)
183+
}
181184
// ensure instances have matching segmentIds with the parts
182185
await updatePartInstancesSegmentIds(context, ingestModel, data.renamedSegments, beforePartMap)
183186

@@ -397,6 +400,34 @@ async function updatePartInstancesSegmentIds(
397400
}
398401
}
399402
if (writeOps.length) await context.directCollections.PartInstances.bulkWrite(writeOps)
403+
404+
// Double check that there are no parts using the old segment ids:
405+
const oldSegmentIds = Array.from(renameRules.keys())
406+
const [badPartInstances, badParts] = await Promise.all([
407+
await context.directCollections.PartInstances.findFetch({
408+
rundownId: ingestModel.rundownId,
409+
segmentId: { $in: oldSegmentIds },
410+
}),
411+
await context.directCollections.Parts.findFetch({
412+
rundownId: ingestModel.rundownId,
413+
segmentId: { $in: oldSegmentIds },
414+
}),
415+
])
416+
if (badPartInstances.length > 0) {
417+
logger.error(
418+
`updatePartInstancesSegmentIds: Failed to update all PartInstances using old SegmentIds "${JSON.stringify(
419+
oldSegmentIds
420+
)}": ${JSON.stringify(badPartInstances)}, writeOps: ${JSON.stringify(writeOps)}`
421+
)
422+
}
423+
424+
if (badParts.length > 0) {
425+
logger.error(
426+
`updatePartInstancesSegmentIds: Failed to update all Parts using old SegmentIds "${JSON.stringify(
427+
oldSegmentIds
428+
)}": ${JSON.stringify(badParts)}, writeOps: ${JSON.stringify(writeOps)}`
429+
)
430+
}
400431
}
401432
}
402433

packages/job-worker/src/ingest/model/IngestSegmentModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface IngestSegmentModel extends IngestSegmentModelReadonly {
6767
setOrphaned(orphaned: SegmentOrphanedReason | undefined): void
6868

6969
/**
70-
* Mark this Part as being hidden
70+
* Mark this Segment as being hidden
7171
* @param hidden New hidden state
7272
*/
7373
setHidden(hidden: boolean): void

packages/job-worker/src/playout/model/implementation/PlayoutModelImpl.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,30 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
751751
if (this.rundownsImpl.find((rd) => rd.AdlibTestingSegmentHasChanged))
752752
logOrThrowError(new Error(`Failed no changes in model assertion, an AdlibTesting Segment has been changed`))
753753

754-
if (
755-
Array.from(this.allPartInstances.values()).find(
756-
(part) => !part || part.partInstanceHasChanges || part.changedPieceInstanceIds().length > 0
757-
)
754+
const changedPartInstances = Array.from(this.allPartInstances.entries()).filter(
755+
([_, partInstance]) =>
756+
!partInstance ||
757+
partInstance.partInstanceHasChanges ||
758+
partInstance.changedPieceInstanceIds().length > 0
758759
)
759-
logOrThrowError(new Error(`Failed no changes in model assertion, a PartInstance has been changed`))
760+
761+
if (changedPartInstances.length > 0) {
762+
logOrThrowError(
763+
new Error(
764+
`Failed no changes in model assertion, PartInstances has been changed: ${JSON.stringify(
765+
changedPartInstances.map(
766+
([id, pi]) =>
767+
`${id}: ` +
768+
(!pi
769+
? 'null'
770+
: `partInstanceHasChanges: ${
771+
pi.partInstanceHasChanges
772+
}, changedPieceInstanceIds: ${JSON.stringify(pi.changedPieceInstanceIds())}`)
773+
)
774+
)}`
775+
)
776+
)
777+
}
760778

761779
if (span) span.end()
762780
}

0 commit comments

Comments
 (0)