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

Add continuous export #949

Merged
merged 17 commits into from
Nov 26, 2020
Merged

Add continuous export #949

merged 17 commits into from
Nov 26, 2020

Conversation

arielshaqed
Copy link
Contributor

No description provided.

@arielshaqed arielshaqed requested a review from guy-har November 22, 2020 15:14
@arielshaqed arielshaqed force-pushed the feature/534-continuous branch from 529ddbf to c52eefe Compare November 23, 2020 08:58
@codecov-io
Copy link

Codecov Report

Merging #949 (c52eefe) into master (24974e3) will decrease coverage by 0.22%.
The diff coverage is 24.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #949      +/-   ##
==========================================
- Coverage   44.46%   44.23%   -0.23%     
==========================================
  Files         143      143              
  Lines       11486    11560      +74     
==========================================
+ Hits         5107     5114       +7     
- Misses       5743     5807      +64     
- Partials      636      639       +3     
Impacted Files Coverage Δ
catalog/cataloger.go 71.22% <ø> (ø)
db/database.go 0.62% <0.00%> (ø)
export/export.go 0.00% <0.00%> (ø)
export/export_handler.go 22.52% <6.66%> (-3.12%) ⬇️
catalog/cataloger_export.go 68.57% <94.73%> (+2.67%) ⬆️
catalog/cataloger_commit.go 82.60% <100.00%> (ø)
catalog/cataloger_merge.go 73.18% <100.00%> (ø)
catalog/cataloger_create_branch.go 84.90% <0.00%> (-3.78%) ⬇️
catalog/cataloger_create_repository.go 59.25% <0.00%> (-3.71%) ⬇️
config/config.go 33.33% <0.00%> (-0.46%) ⬇️
... and 1 more

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 24974e3...c52eefe. Read the comment docs.

Copy link
Contributor

@guy-har guy-har left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

export/export.go Outdated
Comment on lines 114 to 115
exportConfiguration, err := c.GetExportConfigurationForBranch(repo, branch)
if errors.Is(err, pgx.ErrNoRows) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to return and check a cataloger error instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! It actually returns a db error, the old code was incorrect. Thanks, good catch!

Comment on lines 324 to 336
isContinuous, err := hasContinuousExport(h.cataloger, repo, branch)
if err != nil {
// FAIL this merge: if we were meant to export it and did not then in practice
// there was no merge.
return fmt.Errorf("check continuous export for merge %+v: %w", *merge, err)
}
if !isContinuous {
return nil
}
_, err = ExportBranchStart(h.parade, h.cataloger, repo, branch)
if errors.Is(err, ErrExportInProgress) {
err = nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to take it out to a function, given that exportCommitHook does the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good idea! I thought it would be too hard because of logging and error messages, but it was actually easy...

catalog/cataloger.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Finishing CI, rebasing (might be painful) and merging...

catalog/cataloger.go Outdated Show resolved Hide resolved
export/export.go Outdated
Comment on lines 114 to 115
exportConfiguration, err := c.GetExportConfigurationForBranch(repo, branch)
if errors.Is(err, pgx.ErrNoRows) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! It actually returns a db error, the old code was incorrect. Thanks, good catch!

Comment on lines 324 to 336
isContinuous, err := hasContinuousExport(h.cataloger, repo, branch)
if err != nil {
// FAIL this merge: if we were meant to export it and did not then in practice
// there was no merge.
return fmt.Errorf("check continuous export for merge %+v: %w", *merge, err)
}
if !isContinuous {
return nil
}
_, err = ExportBranchStart(h.parade, h.cataloger, repo, branch)
if errors.Is(err, ErrExportInProgress) {
err = nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good idea! I thought it would be too hard because of logging and error messages, but it was actually easy...

@arielshaqed arielshaqed force-pushed the feature/534-continuous branch 4 times, most recently from 737b336 to b1621a9 Compare November 25, 2020 07:34
Handles a commit or merge occurring concurrently with an export.
Hook onto commits and merges to start an export.  This export will attempt to export to the
branch tip.
This is actually in [the docs](https://golang.org/pkg/time/#pkg-constants):

    To convert an integer number of units to a Duration, multiply:

    ```
    seconds := 10
    fmt.Print(time.Duration(seconds)*time.Second) // prints 10s
    ```

That's due to shortcomings of the Go type system.  But this way is safer, it avoids conversion
to an int type.
Most notably, avoid double updates in ExportBranchDone.
Also extract a smaller interface `cataloger.Exporter`
Package `scany` depends on a different version of `pgx` than the rest of lakeFS.  So
`errors.Is(err, pgx.ErrNoRows)` fails.  Luckily it (sort-of) knows of this issue and
wraps this call inside it as `pgxscan.NotFound`.

Also make `ErrNotFound` wrap `pgx.ErrNoRows` rather than a new error.
Catalog methods do not support transactions anyway.  So there is no way for a hook to use
its transaction.  OTOH, running inside the transaction means all catalog methods that the
hook calls will NOT see the commit or merge.  So fix that.
@arielshaqed arielshaqed force-pushed the feature/534-continuous branch from b1621a9 to 74527c9 Compare November 25, 2020 08:30
@arielshaqed
Copy link
Contributor Author

@nopcoder please verify the rebase went well, I made a few changes (but fewer than I expected...).

@arielshaqed arielshaqed requested a review from nopcoder November 25, 2020 08:38
catalog/cataloger.go Outdated Show resolved Hide resolved
catalog/mvcc/cataloger_commit_test.go Outdated Show resolved Hide resolved
catalog/mvcc/cataloger_diff_test.go Show resolved Hide resolved
catalog/mvcc/cataloger_merge_test.go Show resolved Hide resolved
catalog/mvcc/cataloger_merge_test.go Outdated Show resolved Hide resolved
export/export.go Show resolved Hide resolved
Copy link
Contributor Author

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

catalog/cataloger.go Outdated Show resolved Hide resolved
catalog/mvcc/cataloger_diff_test.go Show resolved Hide resolved
export/export.go Show resolved Hide resolved
@arielshaqed arielshaqed requested a review from nopcoder November 25, 2020 11:58
@arielshaqed arielshaqed force-pushed the feature/534-continuous branch from 4a3a5ce to eeeed6d Compare November 25, 2020 15:04
@arielshaqed
Copy link
Contributor Author

Yay! 🥳

Pulling, thanks @guy-har + @nopcoder ...

@arielshaqed arielshaqed merged commit 84a52ee into master Nov 26, 2020
@arielshaqed arielshaqed deleted the feature/534-continuous branch November 26, 2020 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants