filter-process: fix reading 1024 byte files#1699
Conversation
| echo "skip: $0 git version does not include support for filter protocol" | ||
| exit | ||
| fi | ||
| ensure_git_version_isnt $VERSION_LOWER "2.11.0" |
There was a problem hiding this comment.
This seems to work but it still generates a few error messages:
test/testhelpers.sh: line 416: 10#rc2: value too great for base (error token is "10#rc2")
test/testhelpers.sh: line 420: 10#rc2: value too great for base (error token is "10#rc2")
See: https://travis-ci.org/git-lfs/git-lfs/jobs/177907753
... Oh, a few lines down I read this:
skip: test/test-install-custom-hooks-path-unsupported.sh (git version > 2.9.0)
The git version is clear greater than 2.9, right?
However, this is a separate issue and unrelated to the 1024 error.
There was a problem hiding this comment.
These "custom hook paths" tests have two parts:
- The
test/test-install-custom-hooks-path-unsupported.shruns in versions of Git that don't support custom hooks paths (i.e., Git <2.9.0), and ensures that the custom hooks directory is ignored, and the hooks are placed in.git/hooks/. - the
test/test-install-custom-hooks-path.shruns on versions of Git that do support custom hooks paths (i.e., Git >=2.9.0), and ensures that the custom hooks directory is respected.
There's no (current) clean way to do this in one file, so I split it into two, and only one of them runs at a time.
If we read exactly the number of bytes that fit into `p` then implementation detected already an "overfilled" buffer and returned the number of read bytes `n` and `nil` as error. Fix this by treading the exact number not as "overfill". This way the next `readPacket()` call we will read an empty chunk and `read()` will return the number of read bytes `n` and `o.EOF` as (legitmate) error. c.f. #1697
2c0a349 to
53fcd96
Compare
|
Heads up: this seems to work for me on macOS and Linux but I have a hanging process on Windows. Unfortunately I cannot share the repository that creates the hanging process and I haven't been able to create a small test case, yet. |
Are you running Go 1.7.3 on the Windows box? |
|
Ah!! There was something about 1.7... ... let me try! |
|
OK, I am convinced that this is the correct solution. Here's why: When we try to clean a file, the first thing that we do is see if that file is already an LFS pointer, and if it is, we pass that file through directly. To check if the file is an LFS pointer, we only read part of it, since the whole file could be rather large. We read the first 1024 bytes of the file (as dictated by the We buffer the data in that read by passing it through a However! Our
This is totally valid according to the Go documentation for the
Since we filled the buffer, and didn't reach into the next packet (which would have been a This fix is correct because it combines the last read into:
because the reader reads packets until it has to buffer, not until the given This behavior is covered under our unit tests here and here. |
technoweenie
left a comment
There was a problem hiding this comment.
The fix and explanations make sense to me 👍
|
I'd be happy to test this new version on my set of test data (the data that found this issue). It totals about 10GB and 138000 files. Would you happen to have a 64-bit linux binary handy? |
`n`, representing the total number of bytes we have read into `p`, can never become `>len(p)`. As such, let's remove a check for that impossible condition.
|
@eminence: sure. Here are builds for both AMD64 and 386 architectures built against Linux containing all of the commits in this PR: ~/g/git-lfs (lars/test-1024-error) $ git show -q HEAD
commit 0899760263ad35ef11bd7e8af2799b8ea33ae624
Author: Taylor Blau <me@ttaylorr.com>
Date: Tue Nov 22 10:57:18 2016 -0700
git: remove extraneous length check
`n`, representing the total number of bytes we have read into `p`, can never
become `>len(p)`. As such, let's remove a check for that impossible condition.git-lfs-linux-386-1.5.0.tar.gz |
|
Thanks! It's been running for about 30 minuets now with no errors. I'll report back here when it completes. Edit: just finished! Took 32minutes in total. |
Backport #1699 for v1.5.x: filter-process: fix reading 1024 byte files
Apparently the process-filter does not work with Go below version 1.7 cf. #1699 (comment)
Apparently the process-filter does not work with Go below version 1.7 cf. git-lfs/git-lfs#1699 (comment) Former-commit-id: d99f597a8b6072113cebb7f77d9c66d0d1dc449d
Because full support of the "filter" attribute and protocol were only introduced with Git version 2.11.0, we require at least that version of Git for our t/t-filter-process.sh test script. This attribute and the associated protocol were developed in part so as to make the Git LFS client's integration with Git more efficient. The original version of the t/t-filter-process.sh test script predated the release of Git v2.11.0, so when it was introduced in commit d1dca3e of PR git-lfs#1617, it included a workaround technique for detecting whether the version of Git in use did or did not support the "filter" attribute yet. This workaround was preceded by a comment describing how it worked. In commit 54ddc13 of PR git-lfs#1699 the workaround was removed and replaced with a call to the ensure_git_version_isnt() function from our t/testhelpers.sh shell library, since Git version 2.11.0 had been released and so we could perform a simpler version check to confirm whether Git supported the "filter" attribute. However, the comment describing the original workaround technique for detecting support for the "filter" attribute was left in place, so we update it now.
Because full support of the "filter" attribute and protocol were only introduced with Git version 2.11.0, we require at least that version of Git for our t/t-filter-process.sh test script. This attribute and the associated protocol were developed in part so as to make the Git LFS client's integration with Git more efficient. The original version of the t/t-filter-process.sh test script predated the release of Git v2.11.0, so when it was introduced in commit d1dca3e of PR git-lfs#1617, it included a workaround technique for detecting whether the version of Git in use did or did not support the "filter" attribute yet. This workaround was preceded by a comment describing how it worked. In commit 54ddc13 of PR git-lfs#1699 the workaround was removed and replaced with a call to the ensure_git_version_isnt() function from our t/testhelpers.sh shell library, since Git version 2.11.0 had been released and so we could perform a simpler version check to confirm whether Git supported the "filter" attribute. However, the comment describing the original workaround technique for detecting support for the "filter" attribute was left in place, so we update it now.
c.f. #1697