Skip to content

Commit

Permalink
More accurate check for whether a predicate should be derived increme…
Browse files Browse the repository at this point in the history
…ntally

Summary:
If we didn't derive the predicate in the base DB, then we have to do a
full derivation in the stacked DB.

Reviewed By: pepeiborra

Differential Revision: D52484453

fbshipit-source-id: 2e638ed9e181f936f6b46e8619cef9a83e4c2c05
  • Loading branch information
Simon Marlow authored and facebook-github-bot committed Jan 3, 2024
1 parent 1ccc3bb commit efda24a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions glean/db/Glean/Query/UserQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,10 @@ userQueryWrites env odb config bounds lookup repo pred q = do
where
-- We derive incrementally if
-- 1. the DB is stacked, and
-- 2. the base DB also has the predicate we want to derive in its
-- stored schema.
-- 2. the predicate was derived in the base DB
--
-- (2) might be false if we stacked a DB with
-- --update-schema-for-stacked set, for testing derivation.
-- (2) might be false if we're deriving a predicate in a
-- stacked DB that we didn't derive on the base DB.
shouldDeriveIncrementally meta =
case Thrift.metaDependencies meta of
Just (Thrift.Dependencies_stacked Thrift.Stacked{..}) ->
Expand All @@ -585,11 +584,9 @@ userQueryWrites env odb config bounds lookup repo pred q = do
check (Thrift.pruned_base pruned)
Nothing -> return False
where
check base =
withOpenDatabase env base $ \OpenDB{..} ->
case HashMap.lookup pred (predicatesById odbSchema) of
Nothing -> return False
Just PredicateDetails{..} -> return predicateInStoredSchema
check base = do
meta <- atomically $ Catalog.readMeta (envCatalog env) base
return $ predicateIdRef pred `elem` Thrift.metaCompletePredicates meta

-- Here the best we can do is say whether a Pid could have facts in a DB.
-- Because of ownership slicing it may be that even though
Expand Down

0 comments on commit efda24a

Please sign in to comment.