Skip to content

Commit

Permalink
Fix publishing race condition
Browse files Browse the repository at this point in the history
A race condition for publishing packages and
mirrors at the same time was introduced in
commit 77d7c38.

The problem is that when opening a leveldb transaction
and performing another 'put' to the db
the system freezes.
  • Loading branch information
randombenj committed May 31, 2023
1 parent 1501a4e commit ecc0551
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions deb/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
list.PrepareIndex()
}

transaction, err := collection.db.OpenTransaction()
if err != nil {
return nil, nil, err
}
defer transaction.Discard()

checksumStorage := checksumStorageProvider(transaction)
checksumStorage := checksumStorageProvider(collection.db)

for _, file := range packageFiles {
var (
Expand Down Expand Up @@ -201,7 +195,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
continue
}

err = collection.UpdateInTransaction(p, transaction)
err = collection.Update(p)
if err != nil {
reporter.Warning("Unable to save package %s: %s", p, err)
failedFiles = append(failedFiles, file)
Expand All @@ -227,6 +221,6 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
processedFiles = append(processedFiles, candidateProcessedFiles...)
}

err = transaction.Commit()
err = nil // reset error as only failed files are reported
return
}

0 comments on commit ecc0551

Please sign in to comment.