Repository navigation
Description
Hello git-lfs developers. First, thanks for your nice work.
Now to the point: recently we started experiencing hangs in git-lfs during git checkout. At seemingly random moment during the checkout, but reproducible always at the same moment, with same reproducing steps. It was after upgrading the server (Atlassian BitBucket Server) to newer version, so that was the first suspect. However at the server everything was looking alright, and even if it was servers fault, I would expect the git-lfs client to fail, but not hang.
So I tried debugging the client. With GIT_TRACE it looked quite normal, but did just hang at one point, the last many trace lines being "filepathfilter: accepting <path>". Ending always with the same path when repeating same clone/checkout sequence, but with another sequence of checkouts that file gets downloaded successfully, and hang occurs on elsewhere, it's not about that particular file. No apparent failures in the trace or anything interesting what I could post here as symptoms. And when I tried with GIT_CURL_VERBOSE, the problem was gone. So clearly a timing issue.
I still didn't have much to post here, so tried digging into git-lfs source code. Now it got more interesting. Increasing defaultBatchSize in transfer_queue.go, problem gone. Decreasing it to 1, and now it's reproducible much more easily, and even with GIT_CURL_VERBOSE, nice. But still no idea about the cause, all the HTTP requests and responses looking alright. Then I added additional trace messages at multiple places, and this one finally seems to shed some light on it:
diff --git a/tq/transfer_queue.go b/tq/transfer_queue.go index 89296a64..4c7e8585 100644 --- a/tq/transfer_queue.go +++ b/tq/transfer_queue.go
@@ -419,6 +428,7 @@ func (q *TransferQueue) collectBatches() {
time.Sleep(minWaitTime)
} else if len(next) == 0 && len(pending) == 0 {
// There are no items remaining, it is safe to break
+ tracerx.Printf("break on no pending")
break
}
}
This added trace message now appears in the trace log shortly before the hang. After it there are no more downloads, only a bunch of those "accepting <path>" messages and then it hangs.
Looking at the code and trace again, it seems like the downloading loop stops when there is a pause between requests from the running git checkout, big enough for previous downloads to complete during that pause. And then new loop is not started anymore, and it just hangs.
I might be interpreting it wrongly, but hopefully someone here can assess the situation easily.
Let me know if I should post some logs. The issue happens with git-lfs 2.8.0, as well as current master, and also 2.7.X. Git versions tested are 2.20 and 2.23. Everything on Windows 10. Server is BitBucket 6.5.1.
In our case, we use additional inhouse smudge filter for some other files, together with LFS for large binaries, so that probably contributes to longer pauses between requests to the git-lfs-filter-process (there are runs of that other filter between LFS requests).
And why this started happening after upgrade of BitBucket server? Maybe just a coincidence, or maybe the server now handles LFS requests faster. For a while I though it might be because we also enabled HTTP/2 support on the server, but reverting that doesn't help.
Activity
bk2204 commentedon Sep 3, 2019
Hey,
Thanks for this report. We've seen reports of this issue before, but haven't been able to track it down. This is comprehensive and helpful, and I'm now able to reproduce the issue with the following patch:
I'm not exactly sure why this is happening, but now that it's reproducible, it should be a lot easier to fix. I hope to get some time over the next couple of days to look at this issue further.
bk2204 commentedon Sep 3, 2019
I've pushed a branch up to my remote called
tq-hang. Can you try building it and seeing if it fixes the problem you're experiencing?Just as a note, it's probably better to add my remote as a remote to your existing repository, since Go will build the main repo (without the fix) if you clone it into a separate path.
r0nw commentedon Sep 3, 2019
Thanks, that seems to fix it, I cannot reproduce it anymore. Also your change seems logical and consistent with my previous observations, so I believe it's really fine now.
bk2204 commentedon Sep 4, 2019
Great, I'll get a PR opened and ping you on it. Thanks again for a helpful report.
mdeisher commentedon Mar 25, 2020
This seems to be back in 2.10.0.
bk2204 commentedon Mar 25, 2020
Since what you're experiencing is likely a new issue with a new cause, can you open a new bug report issue, filling out the form fully?
mdeisher commentedon Mar 25, 2020