How to resume stuck sys_dm_run and sys_dm_chunk records for "DM Table Cleaner" jobSummary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } While DM Table Cleaner job executes, its possible that sys_dm_run records might get stuck in 'processing', 'timeout', 'active' state. Similarly sys_dm_chunk records might get stuck in 'timeout', 'processing', or 'active' state. As a result newer records may not be created by DM Producer Job until these are resumed due to existing PRBs. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Xanadu and higher releases Instructions<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Execute the Script shown below to resolve the stuck records in sys_dm_run and sys_dm_chunk records. Set it up to run on an hourly basis from sysauto_script if required. ////////// Reset sys_dm_chunks to 'ready' ///////////// /** Resets sys_dm_chunk records to 'ready' if: * - `state` is one of ['timeout', 'processing', or 'active'] * - `start` is more than than CHUNK_CUTOFF_HOURS hours ago * - they do not belong to a sys_dm_run record in 'error' state **/ var CHUNK_CUTOFF_HOURS = 5; var gaRuns = new GlideAggregate('sys_dm_run'); gaRuns.addQuery('state', 'error'); gaRuns.groupBy('sys_id'); // Ensures distinct results gaRuns.query(); var errorRunIds = []; while (gaRuns.next()) { errorRunIds.push(gaRuns.getValue('sys_id')); } gs.info("Found "+ errorRunIds.length +" sys_dm_run records in 'error' state."); gs.log("Updating sys_dm_chunk records from ['processing', 'timeout', 'active'] --> 'ready'"); var grChunk = new GlideRecord('sys_dm_chunk'); grChunk.addQuery('state', 'IN', ['timeout', 'processing', 'active']); grChunk.addQuery('run_id', 'NOT IN', errorRunIds.join(',')); var dteCutoff = new GlideDateTime(); dteCutoff.addSeconds(-1 * CHUNK_CUTOFF_HOURS *3600); // 5 hours grChunk.addQuery("start", "<", dteCutoff); grChunk.setValue("state", "ready"); grChunk.setValue('start', null); grChunk.setValue('claimed_by', null); grChunk.updateMultiple(); ////////// Reset parent sys_dm_run from 'timeout' --> 'processing' or 'complete ////////// gs.log("Updating sys_dm_run records to 'processing' or 'complete'."); var grRunsUpdate = new GlideRecord('sys_dm_run'); grRunsUpdate.addQuery('state', 'timeout'); grRunsUpdate.query(); while (grRunsUpdate.next()) { var runId = grRunsUpdate.getUniqueValue(); var gaChunkCount = new GlideAggregate('sys_dm_chunk'); gaChunkCount.addQuery('run_id', runId); gaChunkCount.addQuery('state', 'ready'); gaChunkCount.addAggregate('COUNT'); gaChunkCount.query(); var cnt = 0; if (gaChunkCount.next()) cnt = gaChunkCount.getAggregate('COUNT'); var newState = cnt > 0 ? 'processing' : 'complete'; var newEnd = cnt > 0 ? null : new GlideDateTime(); gs.log("Changing sys_dm_run ("+ runId +") state '"+ grRunsUpdate.getValue('state') +"' --> '"+ newState +"'"); grRunsUpdate.setValue('state', newState); grRunsUpdate.setValue('end', newEnd); grRunsUpdate.update(); }