Browse Source

Do not block the database during archive creation

pull/27563/head
Matthias Riße 6 months ago
parent
commit
170177c405
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      services/repository/archiver/archiver.go

+ 15
- 0
services/repository/archiver/archiver.go View File

@@ -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)
}
@@ -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 {

Loading…
Cancel
Save