View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002804||Ham Radio Deluxe||Bug||public||2018-07-05 17:06||2018-07-25 20:47|
|Platform||Intel i7-5960X||OS||Windows 10 Professional x64||OS Version||16299|
|Target Version||Fixed in Version||220.127.116.113|
|Summary||0002804: Logbook: DX Lookup code builds bad SQL, causes bad results and repeated SQL errors|
|Description||The Logbook DX Cluster code will repeatedly issue bad SQL statements against the database. These statements are syntactically incorrect and cause an error, which the application simply ignores, failing to consider the desired outcome of the SQL statement against the spot provided.|
|Steps To Reproduce||1) Fire up the logbook|
2) Open a database. The larger the database, the better
3) Conenct to a DX cluster
4) Observe the logfile window.
BUG#1) Eventually, you'll find an error message like this:
13:26:56 DX Lookup Error: Callsign lookups - 13:26:56 DX Lookup Error: Call ......: KA4TLC - 13:26:56 DX Lookup Error: Band ......: 15M - 13:26:56 DX Lookup Error: Mode ......: DIGI - 13:26:56 DX Lookup Error: Database ..: HRDBlank - 13:26:56 DX Lookup Error: Incorrect syntax near the keyword 'OR'.
This error is caused by a race condition, so it won't always happen. Try again, if it doesn't. It might take several tries.
|Tags||No tags attached.|
The Logbook DX Cluster feature relies on some SQL statements to get data from the database to see if a particular spot has been worked before -- and does so along a few different dimensions: call itself, band, mode, band+mode, and so on. The queries can get a little bit involved. Some feature long sequences of conjunctions which become part of a filter.
For example, we want to know if a particualr mode has been involved with a call, but only among a certain DXCC entity, and only in certain modes. The list of modes is pretty long. To save time, the list of modes expressed in a SQL string is pre-formed just once and repeatedly concatenated to any statement which might need it.
The bug is this: that the code which builds those statements is not thread safe. One example is the function GetPhoneSQLString(), which causes the specific bad SQL in this issue. The function tests a static to see if the static is populated; if not, it begins building the string. If two threads arrive at this function and both begin building the string, the end up walking on eachother because there's no locking over the initialization or access to the string. An example of the bogus SQL is here:
SELECT COL_MODE FROM [TABLE_HRD_CONTACTS_V01] WHERE (COL_DXCC = '291') AND NOT ((COL_MODE = 'CW') OR ( OR (COL_MODE = 'SSTV') OR (COL_MODE = 'MABELL'))(COL_MODE = 'USB') OR (COL_MODE = 'LSB') OR (COL_MODE = 'AM') OR (COL_MODE = 'FM') OR (COL_MODE = 'SSTV') OR (COL_MODE = 'MABELL'))) AND ( (COL_QSL_RCVD NOT LIKE 'N%') OR (COL_EQSL_QSL_RCVD NOT LIKE 'N%') OR (COL_LOTW_QSL_RCVD NOT LIKE 'N%') )
The second top-level OR clause comes from GetPhoneSQLString(), and we can see that it is a combination of multiple filter strings.
A fix is available at this shelved change set
fixed with this checkin
||I do not see those error messages.|
||I tested and no longer see these.|
|2018-07-05 17:06||K7ZCZ||New Issue|
|2018-07-06 09:44||K7ZCZ||Summary||Logbook: DX Lookup code buidls bad SQL, causes bad results and repeated SQL errors => Logbook: DX Lookup code builds bad SQL, causes bad results and repeated SQL errors|
|2018-07-06 09:44||K7ZCZ||Steps to Reproduce Updated||View Revisions|
|2018-07-06 09:50||K7ZCZ||Note Added: 0005615|
|2018-07-06 15:06||K7ZCZ||Note Added: 0005620|
|2018-07-07 09:26||K7ZCZ||Assigned To||=> K7ZCZ|
|2018-07-07 09:26||K7ZCZ||Status||new => resolved|
|2018-07-07 09:26||K7ZCZ||Resolution||open => fixed|
|2018-07-07 09:26||K7ZCZ||Note Added: 0005628|
|2018-07-12 14:35||K7ZCZ||Fixed in Version||=> 18.104.22.1684|
|2018-07-13 15:21||g3ucq||Note Added: 0005676|
|2018-07-17 16:44||WA9PIE||Status||resolved => closed|
|2018-07-17 16:44||WA9PIE||Testing||Not Started => Beta Successful|
|2018-07-17 16:44||WA9PIE||Note Added: 0005722|
|2018-07-23 22:52||WA9PIE||Project||3 - Current Dev List => Ham Radio Deluxe|
|2018-07-24 15:36||WA9PIE||Project||Ham Radio Deluxe => 3 - Current Dev List|
|2018-07-25 08:00||WA9PIE||Fixed in Version||22.214.171.1244 => 126.96.36.1993|
|2018-07-25 20:47||WA9PIE||Project||3 - Current Dev List => Ham Radio Deluxe|