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

Update-ZLocation takes a long time; errors after second call #85

Open
vvuk opened this issue Aug 19, 2019 · 6 comments
Open

Update-ZLocation takes a long time; errors after second call #85

vvuk opened this issue Aug 19, 2019 · 6 comments

Comments

@vvuk
Copy link

vvuk commented Aug 19, 2019

On a fresh install, deleting ~/z-location.db and not calling Update-Location from prompt, doing it manually results in:

  1. first Update-ZLocation $pwd call takes ~3-4s
  2. second Update-ZLocation $pwd call throws:
Exception calling "Insert" with "1" argument(s): "Cannot insert duplicate key in unique index '_id'. The duplicate value is '"C:\\Users\\vladv"'."
At C:\Users\vladv\Documents\PowerShell\Modules\ZLocation\1.2.0\ZLocation.LiteDB.psm1:19 char:5
+     $collection.Insert((ToDocument $item)) | out-null
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : LiteException

pwsh 7.0-preview2, Windows 10

@vors
Copy link
Owner

vors commented Aug 20, 2019

Interesting, thank you for the report.

@scottbilas
Copy link

@vors I just started running into this exact problem myself, after a couple months of using this module hundreds of times every day without issue. I have no idea what I may have done to get into the state it's in, but as this is a crucial tool for me, I am super motivated to help narrow down the problem. :D

Do you have any suggestions of things I might try?

@vors
Copy link
Owner

vors commented Aug 20, 2019

@scottbilas hey, thank you for chiming in! The tool is fairly small and all pure powershell - if you have this state on hands, it should be fairly straightforward to interactively debug it. Roughly speaking, add Write-Host to few places to see what's the state. It sounds like somehow we are failing to de-duplicate adding a key to the db. Perhaps poke the db directly to see the state.
It would be really awesome, if you can figure this out since it looks like you need to be in this state to understand what happens.

@scottbilas
Copy link

Now the problem isn't reproducing for me. Perhaps a reboot.. Anyway when it pops up again I'll do the investigation you suggest.

@vvuk
Copy link
Author

vvuk commented Aug 23, 2019

I did some digging -- for anUpdate-ZLocation call, the call to DBGetById takes 8.7s for me. Everything else is trivial time -- this happens whether the Update-ZLocation succeeds or fails.

@uglycoyote
Copy link

I tried installing under Powershell 7 today, but just the initial Import-Module paused for about 2 minutes and emitted an error similar to the one above, with Cannot insert duplicate key in unique index '_id'.

After the Import-Module finished I pressed enter at the command prompt and it took a good 20 seconds to respond, and then responded with just PS> (not my custom-configured prompt). each time I press enter it takes another 20 seconds for the prompt to respond.

I was hoping for a good alternative to tkellogg/Jump-Location because that wasn't working so well for me either, but this is clearly unusable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants