list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <>
To: Son Luong Ngoc <>
Subject: Re: Git pull stuck when Trace2 target set to Unix Stream Socket
Date: Mon, 13 Apr 2020 13:18:12 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Mon, Apr 13, 2020 at 02:05:00PM +0200, Son Luong Ngoc wrote:

> I am trying to write a simple git trace2 event collector and I notice
> that when git doing git pull with trace events being sent to a unix
> stream socket, the entire operation halted.
> Reproduce as follow:
> ```
> cd git/git
> git config trace2.eventTarget af_unix:stream:/tmp/git_trace.sock
> git config trace2.eventBrief false
> (rm /tmp/git_trace.sock | ) &&  nc -lkU /tmp/git_trace.sock
> # In a different terminal
> git pull # Pull stuck and never complete
> ```

I think the issue is the use of netcat as the server side.

Your git-pull involves multiple simultaneously-running Git processes.
But "nc -k" will only accept() a new client once the old one has
disconnected. So we'd deadlock any time we have this situation:

  - process A opens a stream to the socket, and keeps it open

  - process A spawns process B and waits for it to finish

  - process B tries to open a stream to the socket, which will block
    waiting for netcat to accept()

Now A cannot make forward progress until B finishes, but B will not make
forward progress until A closes the socket.

I was able to reproduce the issue locally, and process "A" was git-pull
and process "B" was git-merge.

Switching to using datagrams ("nc -u" and "af_unix:dgram") makes the
problem go away, because the connections are able to interleave their

> This does not happen when you set eventBrief to true
> ```
> git config trace2.eventBrief true
> ```

I don't know why this would matter (and it didn't seem to in my tests).

> Worth to note that if eventTarget is a file instead of a socket,
> everything works fine.

That makes sense, since their file writes can be interleaved.


  parent reply	other threads:[~2020-04-13 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 12:05 Son Luong Ngoc
2020-04-13 16:00 ` Taylor Blau
2020-04-13 17:19   ` Son Luong Ngoc
2020-04-13 17:23     ` Taylor Blau
2020-04-13 17:18 ` Jeff King [this message]
2020-04-13 18:42   ` Jeff Hostetler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \
    --subject='Re: Git pull stuck when Trace2 target set to Unix Stream Socket' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).