Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still getting missing foreign key exception of pool metadata tables #858

Closed
erikd opened this issue Sep 29, 2021 · 3 comments
Closed

Still getting missing foreign key exception of pool metadata tables #858

erikd opened this issue Sep 29, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@erikd
Copy link
Contributor

erikd commented Sep 29, 2021

While working on another aspect I was getting an error "aggregate functions are not allowed in WHERE" which was then followed (after a roll back to the start of the epoch) by:

DbInsertException "PoolOfflineFetchError"
  ( SqlError
    { sqlState = "23503"
    , sqlExecStatus = FatalError
    , sqlErrorMsg = "insert or update on table \"pool_offline_fetch_error\" violates foreign key \
                                       \constraint \"pool_offline_fetch_error_pmr_id_fkey\""
    , sqlErrorDetail = "Key (pmr_id)=(1312) is not present in table \"pool_metadata_ref\"."
    , sqlErrorHint = ""
    }
  ) 

I have checked that commit d658f38 is present in the branch I am working on.

@erikd erikd added the bug Something isn't working label Sep 29, 2021
@erikd
Copy link
Contributor Author

erikd commented Sep 29, 2021

😢 Turns out the insertOfflineResults function had:

    insert :: (MonadBaseControl IO m, MonadIO m) => FetchResult -> ReaderT SqlBackend m ()
    insert fr =
      case fr of
        ResultMetadata md -> void $ DB.insertPoolOfflineData md
        ResultError fe -> void $ DB.insertPoolOfflineFetchError fe

Probably as the result of a bad git merge.

That should have been using DB.insertCheckPoolOfflineData and DB.insertCheckPoolOfflineFetchError.

To reiterate:

  • The test for this was correctly using the checked versions of these functions
  • The actual real code was using the old unckecked versions of these functions

The solution is to permanently remove the unchecked versions of those functions

@erikd
Copy link
Contributor Author

erikd commented Sep 29, 2021

This affects both master and the latest 11.0.3 release 😢

@erikd erikd changed the title Still getting mssing foreign key exception of pool metadata tables Still getting missing foreign key exception of pool metadata tables Sep 29, 2021
@erikd erikd closed this as completed in 20ce462 Sep 29, 2021
@erikd
Copy link
Contributor Author

erikd commented Sep 29, 2021

This will be in release 11.0.4 .

erikd added a commit that referenced this issue Sep 29, 2021
This was supposed to be fixed in d658f38 but probably due to a git
merge error, the new functions that were supposed to fix this issue were
added but not used.

The fix is to use the checked versions of the functions and completely
remove the unchecked functions so they cannot be called by accident.

Closes: #858
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant