Project

General

Profile

Actions

Bug #21625

closed

Host search using OR on facts finds duplicate records and takes a long time

Added by Marek Hulán about 7 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Search
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1511254

Description of problem:

AND and OR operation is not working on satellite as expected, when trying to filtering host with single filter like “facts.bios_vendor = SeaBIOS” it works fine, but when your try to filter using AND and OR operator its not working as expected, when filtering using AND it gives zero result “facts.bios_vendor = SeaBIOS and facts.architecture = x86_64”, when trying to filter using OR result is unstable as it gives around 1700 number of results even through there is only 10 machines registered with satellite.

How reproducible:
- Under Satellite UI - > Hosts → All Hosts → in search tab
- Try to filter host using any fact ex. “facts.bios_vendor = SeaBIOS”
- Also try to filter using any other fact ex. “facts.architecture = x86_64”
- Now combine search filter using AND and OR operator like below and check the result.
Ex. “facts.bios_vendor = SeaBIOS and facts.architecture = x86_64”
Ex. “facts.bios_vendor = SeaBIOS or facts.architecture = x86_64”

Actual results:
- Observe there is no result when using AND operator
- Observe there is N number of results when using OR operator which is regardless of number of registered clients.

Expected results:
- Should be able to search hosts using AND and OR

Additional info:
Also tried to search using the query structure given on the link “https://github.com/wvanbergen/scoped_search/wiki/Query-language” but still result is not as expected.

Actions #1

Updated by Marek Hulán about 7 years ago

The description is misleading. The error appears when we try to search using host facts and use or operator. E.g. this example

facts.bios_version = 1.9.3-1.fc25 or facts.bios_version = 1.9.1-1.fc24

causes huge load on my DB and the result is list of duplicate host entry.

Actions #2

Updated by Marek Hulán about 7 years ago

The generated SQL query looks like this

Host::Managed Load (103699.2ms)  SELECT  "hosts".* FROM "hosts" INNER JOIN fact_values fact_values_28 ON (hosts.id = fact_values_28.host_id) INNER JOIN fact_names fact_names_28 ON (fact_names_28.id = fact_values_28.fact_name_id) INNER JOIN fact_values fact_values_29 ON (hosts.id = fact_values_29.host_id) INNER JOIN fact_names fact_names_29 ON (fact_names_29.id = fact_values_29.fact_name_id) WHERE "hosts"."type" IN ('Host::Managed') AND (((fact_names_28.name = 'bios_version' AND fact_values_28.value = '1.9.3-1.fc25') OR (fact_names_29.name = 'bios_version' AND fact_values_29.value = '1.9.1-1.fc24'))) ORDER BY "hosts"."name" ASC LIMIT $1 OFFSET $2  [["LIMIT", 20], ["OFFSET", 0]]
Actions #3

Updated by Amit Karsale almost 7 years ago

  • Assignee set to Amit Karsale
Actions #4

Updated by Marek Hulán about 5 years ago

this is potentially resolved by #25897

Actions #5

Updated by Leos Stejskal over 3 years ago

  • Status changed from New to Closed

Hi, I'm closing the issue,
it’s been a while since the last update,
I wasn't able to reproduce it on current develop branch & linked BZ is closed.

Actions

Also available in: Atom PDF