Skip to content

git-lfs hangs on git checkout #3801

Closed

Description

@r0nw

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

  1. bk2204 commented on Sep 3, 2019

    @bk2204
    Member

    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:

    diff --git a/commands/command_filter_process.go b/commands/command_filter_process.go
    index bfef2f91..496b3c54 100644
    --- a/commands/command_filter_process.go
    +++ b/commands/command_filter_process.go
    @@ -7,6 +7,7 @@ import (
     	"os"
     	"strings"
     	"sync"
    +	"time"
     
     	"github.com/git-lfs/git-lfs/errors"
     	"github.com/git-lfs/git-lfs/filepathfilter"
    @@ -99,6 +100,7 @@ func filterCommand(cmd *cobra.Command, args []string) {
     				n = ptr.Size
     			}
     		case "smudge":
    +			time.Sleep(5 * time.Second)
     			w = git.NewPktlineWriter(os.Stdout, smudgeFilterBufferCapacity)
     			if req.Header["can-delay"] == "1" {
     				var ptr *lfs.Pointer
    diff --git a/tq/transfer_queue.go b/tq/transfer_queue.go
    index 89296a64..887ea554 100644
    --- a/tq/transfer_queue.go
    +++ b/tq/transfer_queue.go
    @@ -16,7 +16,7 @@ import (
     )
     
     const (
    -	defaultBatchSize = 100
    +	defaultBatchSize = 10
     )
     
     type retryCounter struct 

    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.

  2. bk2204 commented on Sep 3, 2019

    @bk2204
    Member

    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.

  3. r0nw commented on Sep 3, 2019

    @r0nw
    Author

    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.

  4. bk2204 commented on Sep 4, 2019

    @bk2204
    Member

    Great, I'll get a PR opened and ping you on it. Thanks again for a helpful report.

  5. mdeisher commented on Mar 25, 2020

    @mdeisher

    This seems to be back in 2.10.0.

  6. bk2204 commented on Mar 25, 2020

    @bk2204
    Member

    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?

  7. mdeisher commented on Mar 25, 2020

    @mdeisher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions