3170 views

Description

If a sys_term_config is defined against a particular storage table with a certain search term, *any* CONTAINS or ENDSWITH query against that storage table against that specific search term optimizes erroneously. The optimization is only supposed to kick in when the query is against the specific field therefore incorrect results may be returned when searching against a field that is different from the one that is defined in sys_term_config.

What is Term Optimization?

Term Optimization is a platform feature in Kingston which detects certain types of slow queries and optimizes them for better performance in MySQL.

Steps to Reproduce

  1. Navigate to /cmdb_ci_service_list.do and set model number to a couple arbitrary rows to contain ABC.
  2. Create an entry in sys_term_config:
    • table name: cmdb_ci
    • element name: model_number
    • term: ABC
    • Click Synchronize, and wait for it to finish
    • Click Optimize/Activate
  3. Turn on SQL Debug
  4. Navigate to /cmdb_ci_service_list.do?sysparm_query=model_numberCONTAINSABC
  5. Confirm that query returns the rows where model_number was modified to contain ABC
  6. Confirm that query does a join to a sys_termXX table. This is normal.
  7. Now, navigate go to /cmdb_ci_service_list.do?sysparm_query=nameCONTAINSABC.

Observe the incorrect optimizing even though it is the wrong field.

 

Workaround

If on Kingston through Kingston Patch 4:

Run the following script in scripts background to disable the term optimization feature:

//Start Script
var configs = [];
var gr = new GlideRecord('sys_term_config')
gr.query();
gs.print(gr.getRowCount());
while(gr.next()){
gs.print(gr.sys_id);
new SNC.GlideTermTableAPI().stopOptimizing(gr);
}

//End Script

If on Pre-Kingston:

Run the following script in scripts background to create a property that ensures term optimization is not enabled when upgrading to Kingston. This prevents any impact, and when upgrading to a fixed build the optimization turns back on.

//Start Script
gs.setProperty('glide.db.query.term.table_limit', 0);
//End Script

 


Related Problem: PRB1267268

Seen In

There is no data to report.

Intended Fix Version

London

Fixed In

Kingston Patch 5

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-05-18 07:25:33
Published:2018-04-18