Skip to content

Commit 170177c

Browse files
committed
Do not block the database during archive creation
1 parent 2c7b6c3 commit 170177c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

services/repository/archiver/archiver.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ func doArchive(r *ArchiveRequest) (*repo_model.RepoArchiver, error) {
266266
// TODO: add lfs data to zip
267267
// TODO: add submodule data to zip
268268

269+
// Commit and close here to avoid blocking the database for the entirety of the archive generation process
270+
err = committer.Commit()
271+
if err != nil {
272+
return nil, err
273+
}
274+
committer.Close()
275+
269276
if _, err := storage.RepoArchives.Save(rPath, rd, -1); err != nil {
270277
return nil, fmt.Errorf("unable to write archive: %w", err)
271278
}
@@ -275,6 +282,14 @@ func doArchive(r *ArchiveRequest) (*repo_model.RepoArchiver, error) {
275282
return nil, err
276283
}
277284

285+
txCtx, committer, err = db.TxContext(db.DefaultContext)
286+
if err != nil {
287+
return nil, err
288+
}
289+
defer committer.Close()
290+
ctx, _, finished = process.GetManager().AddContext(txCtx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName()))
291+
defer finished()
292+
278293
if archiver.Status == repo_model.ArchiverGenerating {
279294
archiver.Status = repo_model.ArchiverReady
280295
if err = repo_model.UpdateRepoArchiverStatus(ctx, archiver); err != nil {

0 commit comments

Comments
 (0)