cli icon indicating copy to clipboard operation
cli copied to clipboard

`pscale` hangs for 2 minutes when running in WSL2

Open dbanck opened this issue 1 year ago • 12 comments

Hi!

I noticed a strange behavior when running pscale in WSL2.

  • Release 0.131.0
  • Installed via pscale_0.131.0_linux_amd64.deb
  • WSL2 Ubuntu 20.04.6 LTS

Any command will hang for 2 minutes before any output:

$ time pscale --debug org list
Updater error: skipping update, reason: Latest version was already checked
Error: not authenticated yet. Please run 'pscale auth login'
Error: --access-token is required for access token authentication

________________________________________________________
Executed in  120.11 secs      fish           external
   usr time    4.44 millis   51.00 micros    4.39 millis
   sys time    4.83 millis  114.00 micros    4.72 millis

Running pscale auth login will take 2 minutes until a browser window with the (correct) code is opened and then another ~2 minutes until a success message is shown.

$ time pscale --debug auth login
Confirmation Code: xxx

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=xxx

Successfully logged in.

________________________________________________________
Executed in  275.68 secs      fish           external
   usr time  250.22 millis    0.00 micros  250.22 millis
   sys time  111.74 millis  770.00 micros  110.97 millis

I cannot connect to any database or do any development work in WSL2.

Happy to debug this further with some guidance.

dbanck avatar Mar 20 '23 10:03 dbanck

Just chiming in to say that I'm observing this issue as well in WSL2, running the same version of Ubuntu but using pscale version 0.136.0 at time of writing. There are two details worth mentioning, though:

  1. The first command after a reboot works as expected, but every command after that takes ~2 minutes
  2. I can connect to databases and branches, they are just subjected to the same 2 minute restriction

This issue isn't really a blocker for me because all of the commands work eventually, but it does make demoing Planetscale for my team pretty painful.

puregarlic avatar Apr 13 '23 19:04 puregarlic

Also having this same behaviour with [email protected] installed via brew on Ubuntu 20.04.4 in WSL2.

First command runs as normal. Subsequent commands hang for ~2 minutes before doing anything.

itsjxck avatar Apr 27 '23 08:04 itsjxck

I haven't been able to recreate this yet. Our suspicion is that this has to do with keyring access.

If someone here gets a chance, could you try running pkill gnome-keyring? Then run the pscale command again. I'm curious if that temporarily improves it.

Related issue: https://github.com/99designs/keyring/issues/112

mscoutermarsh avatar Apr 29 '23 12:04 mscoutermarsh

@mscoutermarsh I can confirm that in my instance, this worked:

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 took 4s 
➜ time pscale --help
<snip output>
pscale --help  0.01s user 0.00s system 0% cpu 2:00.11 total

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 took 2m 0s 
➜ pkill gnome-keyring

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 
➜ time pscale --help 
<snip output>
pscale --help  0.01s user 0.00s system 0% cpu 3.215 total

itsjxck avatar Apr 29 '23 16:04 itsjxck

@itsjxck wow, thank you. Will keep looking into the keyring then.

mscoutermarsh avatar Apr 29 '23 16:04 mscoutermarsh

Thanks for looking into this! I can confirm the same behavior with gnome-keyring.

Killing it after each pscale command "works".

dbanck avatar May 02 '23 06:05 dbanck

That partially solves the problem for me. It reduced the time from four minutes down to two minutes. Apparently there is something else going on too.

 ~/repositories  time pscale --version
pscale version 0.136.0 (build date: 2023-04-05T18:22:00Z commit: bd872ad)

real    4m12.467s
user    0m0.013s
sys     0m0.000s
 ~/repositories  pkill gnome-keyring
 ~/repositories  time pscale --version
pscale version 0.136.0 (build date: 2023-04-05T18:22:00Z commit: bd872ad)

real    2m10.787s
user    0m0.006s
sys     0m0.008s
 ~/repositories 

iambillmccann avatar May 03 '23 03:05 iambillmccann

Great info, thank you.

mscoutermarsh avatar May 03 '23 11:05 mscoutermarsh

@mscoutermarsh, if there is other information that would be helpful ... let me know. Also, if the source code is available (is it open source?), I would be willing to run it in a debugger.

Um. NVM, I see the code is here, in this repo. Duh.

iambillmccann avatar May 03 '23 12:05 iambillmccann

@iambillmccann That'd be incredible! No one on our team has been able to reproduce it just yet.

We believe it's likely timing out when accessing the keyring here: https://github.com/planetscale/cli/blob/37460efe0a564dc44d4ec85918f75139389489ce/internal/config/config.go#L214

Or it may be when reading/writing it. https://github.com/planetscale/cli/blob/37460efe0a564dc44d4ec85918f75139389489ce/internal/config/config.go#L237

mscoutermarsh avatar May 03 '23 12:05 mscoutermarsh

Related issue: 99designs/keyring#112

Fwiw, I don't think this issue is just related, but it's exactly this problem that we're hitting here. @iambillmccann You probably end up debugging that package when following the bread crumbs. But if you have any information for us, or for them that would be amazing!

dbussink avatar May 03 '23 12:05 dbussink

I'm having the same issue. CLI version: 0.144.0 Ubuntu version: 22.04.2 (WSL2)

Running pkill gnome-keyring before each command also seems to be working for me.

If there is anything I could help you debugging let me know.

I've put an alias in my .bashrc as workaround:

alias pscale="pkill gnome-keyring && pscale"

simonknittel avatar May 20 '23 06:05 simonknittel