Skip to content

Do not block the database(sqlite) during archive creation #27563

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions services/repository/archiver/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ func doArchive(r *ArchiveRequest) (*repo_model.RepoArchiver, error) {
// TODO: add lfs data to zip
// TODO: add submodule data to zip

// Commit and close here to avoid blocking the database for the entirety of the archive generation process
err = committer.Commit()
if err != nil {
return nil, err
}
committer.Close()

if _, err := storage.RepoArchives.Save(rPath, rd, -1); err != nil {
return nil, fmt.Errorf("unable to write archive: %w", err)
}
Expand All @@ -275,6 +282,14 @@ func doArchive(r *ArchiveRequest) (*repo_model.RepoArchiver, error) {
return nil, err
}

txCtx, committer, err = db.TxContext(db.DefaultContext)
if err != nil {
return nil, err
}
defer committer.Close()
ctx, _, finished = process.GetManager().AddContext(txCtx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName()))
defer finished()

if archiver.Status == repo_model.ArchiverGenerating {
archiver.Status = repo_model.ArchiverReady
if err = repo_model.UpdateRepoArchiverStatus(ctx, archiver); err != nil {
Expand Down