Commit fb8d8645 authored by Klaus Aehlig's avatar Klaus Aehlig

Consider job-IDs queried for twice only once

As reading jobs from disk is an expensive operation, when querying
for jobs, we optimize by considering which values the job-id is asked
for in the filter. As any reasonable person would not add the same
clause twice in an Or-clause, the implicit assumption was that the
job ids obtained by inspecting the filter would be unique; hence the
information for those jobs could be returned directly.

That all did hold true and everyone was happy till with commit 13ef1fa5
a query for a single job suddenly returned the job twice violating
WaitForJobChange's expectation. Fix this by taking the nub of the
jids asked for in the filter.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent adcccd43
......@@ -57,10 +57,10 @@ module Ganeti.Query.Query
) where
import Control.DeepSeq
import Control.Monad (filterM, foldM)
import Control.Monad (filterM, foldM, liftM)
import Control.Monad.Trans (lift)
import qualified Data.Foldable as Foldable
import Data.List (intercalate)
import Data.List (intercalate, nub)
import Data.Maybe (fromMaybe)
import qualified Data.Map as Map
import qualified Text.JSON as J
......@@ -164,6 +164,7 @@ getRequestedJobIDs qfilter =
Nothing -> Ok []
Just [] -> Ok []
Just vals ->
liftM nub $
mapM (\e -> case e of
QuotedString s -> makeJobIdS s
NumericValue i -> makeJobId $ fromIntegral i
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment