2

I encountered a rather strange experience when trying to fetch on my VM that runs ubuntu (host Windows 10). I needed to get the changes from the repo onto my computer, so I used git fetch, except it hanged on the terminal.

So basically I had this ($ is from the terminal, not part of the command):

$ git fetch 
cursor stuck here

Then I tried this (I was hoping it might be stronger than fetch):

$ git fetch --all
cursor stuck here

I ran an strace on the fetch call, and this is something I do not quite understand what happened, but it basically stopped on a line like this:

read(5,

I noticed that some ssh directories did not exist (had some -1 ENOENT errors from the strace), so I tested my ssh commands, and they also hanged. Or at least I thought.

For one of my aliases, it really did seem to hang. However, when I copy/pasted that alias into the terminal it ended up working (just really slowly). Then, I tested my ssh aliases and they started working fine too. Strange...

At this point I tried git fetch again and it worked!!!

However, I have no idea what happened, does anyone have any idea? Is this an issue worth investigating?

Edit:

After completing one fetch call, I could no longer fetch. SSH is now inconsistent. Git pull hangs.

strace on git pull ends with a

wait4(4439, 

Additionally, there seem to be a lot of -1 ENOENT errors complaining about various .git directories.

Is this just a speed thing for ssh and for the git commands something more serious?

EDIT2:

So I tried what was suggested in the comments (setting GIT_TRACE to 2, suing export since I am in ubuntu). It showed what was going on with each git call under the hood, and for some reason git pull/git fetch freeze about halfway through. About 20 minutes later they unfreeze and work again.

I am probably going to leave my computer and restart the vm and look at it tomorrow (long day). Does anyone have any suggestions for speeding this up/why this might be happening?

  • Does your .bashrc on the remote Ubuntu server has any echo in it, anything producing an output? Or even something expecting an input? – VonC Jun 25 '20 at 05:13
  • No echo... also only some ssh aliases work now... Also git pull hangs. The strace on the git pull seems to end with wait4(4439, – Alex Bishka Jun 25 '20 at 05:16
  • 1
    Tru the same commands with GIT_TRACE2_EVENT set (https://stackoverflow.com/a/61315522/6309), assuming Git 2.25 (preferably, 2.27) – VonC Jun 25 '20 at 05:19
  • So I followed the GIT_TRACE stuff, and it's telling me to run a few commands, will try them and see how it goes. Will update after running commands. – Alex Bishka Jun 25 '20 at 05:24
  • 1
    The hang in `read(5,...)` suggests it is waiting for data from somewhere, likely from the server. Is it possible the server or the network connection was hung or slow? The hang in `wait4(...)` means that `git` has spawned a subprocess and is waiting for it, you should trace the subprocess instead to see what it is doing. `pstree` is a good way to find it. – Nate Eldredge Jun 25 '20 at 05:53
  • 1
    The ENOENT errors usually just indicate git looking for optional files that could be in a lot of different places. When a given one is not found it just moves on. This is almost certainly normal behavior and unrelated to your problem. – Nate Eldredge Jun 25 '20 at 05:54
  • 1
    If ssh is also hanging, that sounds like a problem with the server or the network. I don't think the problem is with git itself. – Nate Eldredge Jun 25 '20 at 05:55
  • @NateEldredge I think you may be right, after what I did with the GIT_TRACE suggestion from VonC Is there any reason why things might suddenly be slow? It all worked fine and dandy last night, and I am unsure as to why this may be happening. – Alex Bishka Jun 25 '20 at 06:17
  • @AlexBishka: There's too many possible causes to guess. If it happens again you can try various things to diagnose it; ping, etc. At any rate it is no longer a programming problem, but maybe one of network repair instead; StackOverflow isn't the right place to pursue it. – Nate Eldredge Jun 25 '20 at 06:22
  • @NateEldredge Do you have any suggestions for where I can pursue this? – Alex Bishka Jun 25 '20 at 06:25

1 Answers1

1

@NateElredge seems to be right here, seemed it was a network issue. I think my vm must have been overworked or something, after rebooting both the vm and my host and letting them be off overnight ssh/git fetch/git pull work fine now.

Edit 2: so it seems to just be a virtual box problem. Apparently it just slows down network connections a lot.

Edit 3: the solution to this would be to download a faster terminal. I ended up downloaded Alacritty from here. It works much faster than the default terminal for Ubuntu 20.04 for both git and npm/expo.

For those who don't want to click the link this is the tl;dr:
----------- [Arch Linux] -----------
# pacman -S alacritty

----------- [Fedora Linux] -----------
# dnf copr enable pschyska/alacritty
# dnf install alacritty

----------- [Debian and Ubuntu] -----------
$ sudo add-apt-repository ppa:mmstick76/alacritty
$ sudo apt install alacritty

The only downside to this is that Alacritty does not have terminal windows (at least I can't seem to figure out to use them). However, do not despair, you can just install tmux (for ubuntu: $sudo apt install tmux).