Resolve orphan records in sys_connection and TPC child tables after a cloneIssue <!-- /*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: ; } } Resolve an issue where orphan records appear in the [sys_connection] table and its TPC (table per class) child tables — such as [jdbc_connection] and [http_connection] — after a clone completes. These orphan records occur when the clone exclude and preserve configurations are not aligned for TPC child tables. 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: ; } } All supported releases Cause<!-- /*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: ; } } In the base system clone configuration, both the Exclude and Preserve settings are applied only to the [sys_connection] base table — not to its TPC child tables. A fix for PRB1403259 (Clone — excluding a base TPC table now also excludes child tables) was released on 28 May 2020. As a result of this fix, when [sys_connection] is in the Exclude configuration, the clone automatically excludes its TPC child tables as well — including [jdbc_connection], [http_connection], and [orch_jms_ds]. However, because the Preserve configuration is applied only to [sys_connection] and not to the child tables, the clone excludes the child table data but does not preserve it. After the clone completes, the [sys_connection] base table contains records whose sys_class_name references child table classes — but those child table records were never preserved, creating orphan records. Exclude Config Preserve Config Orphan records example Resolution<!-- /*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: ; } } Step 1: Identify orphan records In Scripts - Background (global scope), run the following script to find orphan records and identify which tables are contributing to them: findOrphans('sys_connection', null, false); // ============== WARNING ================ // // Do not modify anything below this line! // // ======================================= // function findOrphans(table, query, remove) { GlideTransaction.get().setAllowExcessiveLogging(true); if (gs.getCurrentScopeName() != 'rhino.global') { gs.info("This script must be run in the global scope. Please switch your scope and try again."); return; } var orphanCount = 0, removedCount = 0; var gr = new GlideRecord(table); if (query !== null) { gs.info("Querying " + table + " with encoded query: " + query); gr.addEncodedQuery(query); } else gs.info("Querying all rows on " + table); gr.query(); gr.setWorkflow(false); while(gr.next()) { if(isOrphan(gr)) { gs.info("Found orphan on " + table + " (Class: " + gr.sys_class_name + " - Sys ID: " + gr.sys_id + ")"); orphanCount++; } } gs.info("Total orphans found: " + orphanCount); } function isOrphan(gr) { if(gr.sys_class_name == null || gr.sys_class_name == '') return false; var childClass = new GlideRecord(gr.sys_class_name); if(!childClass.isValid()) return true; childClass.get(gr.sys_id); return !childClass.isValidRecord(); } Review the output to confirm the orphan count and which classes are affected before proceeding to cleanup. Step 2: Remove orphan records Warning: This script permanently deletes records. Run step 1 first and verify the output before running this script. Test on a non-production instance before applying to production. In Scripts - Background (global scope), run the following script to delete the orphan records: findOrphans('sys_connection', null, true); // ============== WARNING ================ // // Do not modify anything below this line! // // ======================================= // function findOrphans(table, query, remove) { if (gs.getCurrentScopeName() != 'rhino.global') { gs.info("This script must be run in the global scope. Please switch your scope and try again."); return; } var orphanCount = 0, removedCount = 0; var gr = new GlideRecord(table); if (query !== null) { gs.info("Querying " + table + " with encoded query: " + query); gr.addEncodedQuery(query); } else gs.info("Querying all rows on " + table); gr.query(); gr.setWorkflow(false); while(gr.next()) { if(isOrphan(gr)) { gs.info("Found orphan on " + table + " (Class: " + gr.sys_class_name + " - Sys ID: " + gr.sys_id + ")"); orphanCount++; if (remove === true) { gs.info("Removing orphan"); gr.sys_class_name = table; gr.update(); gr.deleteRecord(); removedCount++; } } } gs.info("Total orphans found: " + orphanCount); gs.info("Total orphans removed: " + removedCount); } function isOrphan(gr) { if(gr.sys_class_name == null || gr.sys_class_name == '') return false; var childClass = new GlideRecord(gr.sys_class_name); if(!childClass.isValid()) return true; childClass.get(gr.sys_id); return !childClass.isValidRecord(); } Step 3: Prevent orphan records in future clones Add the TPC child tables of [sys_connection] to the Preserve configuration on the source instance. At minimum, add the following tables: [jdbc_connection][http_connection][orch_jms_ds]Any other table that extends [sys_connection] To verify which tables extend [sys_connection], go to the [sys_db_object] table and filter for records where Extends = sys_connection. To create a data preserver, see Preserving data from target instances during clones.