Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix manifest rewriting so unit test will pass using a injected latenc…
Browse files Browse the repository at this point in the history
…y on os.file.Sync()
iluminae committed Nov 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent e0eabc6 commit 4f2f2cf
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions manifest.go
Original file line number Diff line number Diff line change
@@ -212,19 +212,17 @@ func (mf *manifestFile) addChanges(changesParam []*pb.ManifestChange) error {
}
// Maybe we could use O_APPEND instead (on certain file systems)
mf.appendLock.Lock()
defer mf.appendLock.Unlock()
if err := applyChangeSet(&mf.manifest, &changes); err != nil {
mf.appendLock.Unlock()
return err
}
if mf.inMemory {
mf.appendLock.Unlock()
return nil
}
// Rewrite manifest if it'd shrink by 1/10 and it's big enough to care
if mf.manifest.Deletions > mf.deletionsRewriteThreshold &&
mf.manifest.Deletions > manifestDeletionsRatio*(mf.manifest.Creations-mf.manifest.Deletions) {
if err := mf.rewrite(); err != nil {
mf.appendLock.Unlock()
return err
}
} else {
@@ -233,12 +231,10 @@ func (mf *manifestFile) addChanges(changesParam []*pb.ManifestChange) error {
binary.BigEndian.PutUint32(lenCrcBuf[4:8], crc32.Checksum(buf, y.CastagnoliCrcTable))
buf = append(lenCrcBuf[:], buf...)
if _, err := mf.fp.Write(buf); err != nil {
mf.appendLock.Unlock()
return err
}
}

mf.appendLock.Unlock()
return syncFunc(mf.fp)
}

0 comments on commit 4f2f2cf

Please sign in to comment.