Skip to content

Commit

Permalink
Fail if cannot construct a valid schema
Browse files Browse the repository at this point in the history
Summary:
We would get an infinite loop under certain circumstances because we store an error value in one of the fields of the `DbSchema` type. See D56519258 for full diagnosis.

This diff makes sure to just fail early if we cannot load an `all` schema.

Reviewed By: bochko

Differential Revision: D56531547

fbshipit-source-id: 2e51946224a4fd2c05369c910988b18080472a84
  • Loading branch information
Josef Svenningsson authored and facebook-github-bot committed Apr 25, 2024
1 parent 6938b05 commit 2ceed47
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions glean/db/Glean/Database/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,12 @@ mkDbSchema toList cacheVar knownPids dbContent
legacyAllVersions =
hashedSchemaAllVersions $ procSchemaHashed latestSchema

latestSchemaId =
case IntMap.lookupMax legacyAllVersions of
Nothing -> error "no \"all\" schema"
Just (_, id) -> id
latestSchemaId <-
case IntMap.lookupMax legacyAllVersions of
Nothing -> throwIO $ ErrorCall "no \"all\" schema"
Just (_, id) -> return id

let
dbSchemaId =
case IntMap.lookupMax (hashedSchemaAllVersions stored) of
Nothing -> error "no \"all\" schema in DB"
Expand Down

0 comments on commit 2ceed47

Please sign in to comment.