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

Indexing sometime fails with SQLite error about UNIQUE constraint failed. #3622

Closed
guibou opened this issue Jun 2, 2023 · 9 comments
Closed
Assignees
Labels
component: hiedb type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@guibou
Copy link
Collaborator

guibou commented Jun 2, 2023

Sometime, during Indexing, hls returns an exception:

HieDb writer thread SQLite error:\n  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ

Your environment

Using NixOS, GHC 9.6.2 (but was happening with 9.6.1 recently), neovim and HLS 1.9.1.0 built from source with minor patchs which should not be relevant (see #TODO)

The project is built with nix with a custom build system and the setup of HLS is done with custom in-house scripts.

Steps to reproduce

I have no idea.

Expected behaviour

Maybe the exception is due to a bug in the indexing mechanism, the exception should not be returned.

Actual behaviour

HieDb writer thread SQLite error:\n  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ

Debug information

Note that I observed this exception and wrote #3610 (comment) because of it. In that MR, I fixed the way HLS was reacted to this exception (it was forgetting to remove the Indexing status), but not the cause of the exception.

@guibou guibou added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Jun 2, 2023
@mjrussell
Copy link
Contributor

mjrussell commented Jul 10, 2023

This exception also occurs for me on a Mac M1 with HLS built from source on feb5965 (HEAD with changes from 2.0.0) and GHC 9.4.5

@guibou
Copy link
Collaborator Author

guibou commented Sep 14, 2023

I realized recently that I have multiples files with the same module name (mostly, Main). Maybe that's the reason of this UNIQUE constraint violation.

@alt-romes
Copy link

alt-romes commented Nov 18, 2023

I've also been affected by this issue, running GHC 9.8, HLS 2.4, Cabal 3.10 installed via GHCup

E:hls: Error condition, please check your setup and/or the [issue tracker](https://github.com/haskell/haskell-language-server/issues): 
HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ

This happens to me everytime I save the file using ALE in vim

@guibou
Copy link
Collaborator Author

guibou commented Dec 30, 2023

@alt-romes

I do observe the issue a lot more since I upgraded to GHC 9.8 too.

@theGhostJW
Copy link

theGhostJW commented Jan 15, 2024

Just upgraded to 9.8.1 and having the same issue (Ubuntu 20.04 (WSL 2)).

Tools

theghostjw@LamdahofLT2:~/pyrethrum/pyrethrum$ ghcup list
[ Warn  ] New stack version available. If you want to install this latest version, run 'ghcup install stack 2.13.1'
   Tool  Version    Tags                      Notes                                                
✔✔ ghc   9.8.1      latest,base-4.19.0.0      hls-powered,2023-10-09                                
✔✔ cabal 3.10.2.1   latest,recommended                                                        
✔✔ hls   2.5.0.0    latest,recommended                                                                        
✔✔ stack 2.11.1                                                                               
✔✔ ghcup 0.1.20.0   latest,recommended        

Typical Log

DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
2024-01-15T04:56:06.157426Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
2024-01-15T04:56:06.826977Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [ClassOp]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
2024-01-15T04:56:07.190638Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
2024-01-15T04:56:07.209218Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
2024-01-15T04:56:07.230044Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
2024-01-15T04:56:07.505066Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
2024-01-15T04:56:08.169099Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
2024-01-15T04:56:08.538883Z | Error | HieDb writer thread SQLite error:
  SQLite3 returned ErrorConstraint while attempting to perform step: UNIQUE constraint failed: defs.hieFile, defs.occ
2024-01-15T04:56:41.448739Z | Info | Live bytes: 214.71MB Heap size: 897.58MB
2024-01-15T04:57:41.510107Z | Info | Live bytes: 214.71MB Heap size: 897.58MB

@theGhostJW
Copy link

stopped happening for me after upgrading 2.5.0.0 ->2.6.0.0

@fendor
Copy link
Collaborator

fendor commented Jan 20, 2024

@guibou Can you confirm this isn't happening on HLS 2.6.0.0?

@wz1000
Copy link
Collaborator

wz1000 commented Jan 20, 2024

In 2.6.0.0, #3943 fixed one source of these coming from changes to how namespaces work for record fields in GHC 9.8. Any failures on GHC 9.6 or below are due to another undiagnosed cause and are not fixed, so I think this ticket should stay open.

If there is a reproducer for these errors affecting HLS 2.6.0.0 or any HLS version with a GHC < 9.8, I can take a look. I'm pretty sure that it wouldn't take a contrived set of circumstances to reproduce these failures, so any reproducer would be as simple as "try loading this code into HLS".

@guibou
Copy link
Collaborator Author

guibou commented Jan 23, 2024

Working with HLS 2.6.0.0 and updated ghcide since a few hours now and no failure, so #3943 definitvely fixed the important stream of error I had since upgrading to GHC 9.8.

I think we can close the issue, I'll reopen if an error happen again.

Thank you.

@guibou guibou closed this as completed Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hiedb type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

7 participants