Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pooled and buffered gzip implementation #5722

Merged

Conversation

zeripath
Copy link
Contributor

This PR reimplements the gzip middleware implementation with a pooled and buffered gzip implementation. It more properly handles gzipped content and zipped content.

It should fix #5182 & fix #4853.

@codecov-io
Copy link

codecov-io commented Jan 13, 2019

Codecov Report

Merging #5722 into master will increase coverage by 0.17%.
The diff coverage is 59.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5722      +/-   ##
==========================================
+ Coverage   37.73%   37.91%   +0.17%     
==========================================
  Files         327      328       +1     
  Lines       47895    48084     +189     
==========================================
+ Hits        18074    18229     +155     
- Misses      27222    27238      +16     
- Partials     2599     2617      +18
Impacted Files Coverage Δ
routers/routes/routes.go 85.05% <0%> (ø) ⬆️
models/lfs.go 39.13% <42.85%> (+10.86%) ⬆️
modules/gzip/gzip.go 60.84% <60.84%> (ø)
models/unit.go 0% <0%> (-14.29%) ⬇️
modules/process/manager.go 76.81% <0%> (-4.35%) ⬇️
models/repo_indexer.go 48.3% <0%> (+3.81%) ⬆️
modules/lfs/server.go 44.27% <0%> (+6.46%) ⬆️
modules/lfs/content_store.go 51.56% <0%> (+7.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0756495...49fc075. Read the comment docs.

@bkcsoft bkcsoft added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 13, 2019
@lunny
Copy link
Member

lunny commented Jan 14, 2019

@zeripath could you add some integration tests?

@lunny lunny added the type/bug label Jan 14, 2019
@lunny lunny added this to the 1.8.0 milestone Jan 14, 2019
@zeripath
Copy link
Contributor Author

zeripath commented Jan 14, 2019

OK I've added a simple test, and an integration test that will get from the LFS store objects which are expected to be compressed and not compressed. The integration test basically requires running the suite with gzip enabled and without gzip enabled - which is probably reasonable given we missed a problem with gzip although it does make our test suite very long. I am happy to drop the integration test doubling if you think that the basic test would be sufficient.


Actually I've just made the sqlite integration test run with gzip enabled. It seemed the most simple way.

@zeripath
Copy link
Contributor Author

zeripath commented Jan 14, 2019

Thinking on, although that trick with Enable_gzip and then rerun integration tests doesn't actually fail it is remarkably inefficient in that only my integration test actually runs differently.

@lunny is the simple gzip_test sufficient or do you want integration tests. I can make it so that our integration tests actually deal with gzip'd content in general if you like.


I'm actually wrong here, unless we turn it off http.Transport will transparently ask for gzip and decompress. So the integration test is good.

Now I just need to work out what postgres is complaining about.

@zeripath
Copy link
Contributor Author

Ah it looks like my integration test is hitting go-testfixtures/testfixtures#39

@zeripath zeripath force-pushed the issue-5182-better-gzip-encoder-management branch from 6d70b15 to e61c98e Compare January 15, 2019 19:22
@zeripath
Copy link
Contributor Author

I've just rebased and squashed up some of the results.

models/lfs.go Show resolved Hide resolved
The previous code made it possible for a race condition to occur whereby a LFSMetaObject could be checked into the database twice. We should check if the LFSMetaObject is within the database and insert it if not in one transaction.
The integration tests are being affected by
go-testfixtures/testfixtures#39 if we set the
primary key high enough, keep a count of this and remove at the end of
each test we shouldn't be affected by this.
@zeripath zeripath force-pushed the issue-5182-better-gzip-encoder-management branch from 75bffac to 20aef08 Compare January 20, 2019 12:30
@bkcsoft bkcsoft added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 22, 2019
@lafriks
Copy link
Member

lafriks commented Jan 22, 2019

@lunny need your review

@bkcsoft bkcsoft added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 23, 2019
@lafriks lafriks merged commit 7d43437 into go-gitea:master Jan 23, 2019
@zeripath zeripath deleted the issue-5182-better-gzip-encoder-management branch January 23, 2019 20:20
bmackinney pushed a commit to bmackinney/gitea that referenced this pull request Jan 27, 2019
* Pooled and buffered gzip implementation

* Add test for gzip

* Add integration test

* Ensure lfs check within transaction

The previous code made it possible for a race condition to occur whereby a LFSMetaObject could be checked into the database twice. We should check if the LFSMetaObject is within the database and insert it if not in one transaction.

* Try to avoid primary key problem in postgres

The integration tests are being affected by
go-testfixtures/testfixtures#39 if we set the
primary key high enough, keep a count of this and remove at the end of
each test we shouldn't be affected by this.
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
8 participants