Skip to content
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

Fix data race in hash-based sync #2159

Merged
merged 1 commit into from
Apr 19, 2023
Merged
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
8 changes: 6 additions & 2 deletions cmd/zc_traverser_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ func (t *localTraverser) prepareHashingThreads(preprocessor objectMorpher, proce
return err
}
}
processor = mutexProcessor(processor)

// spin up hashing threads
for i := 0; i < hashingThreadCount; i++ {
Expand Down Expand Up @@ -575,7 +576,7 @@ func (t *localTraverser) prepareHashingThreads(preprocessor objectMorpher, proce
noMetdata,
"", // Local has no such thing as containers
),
mutexProcessor(processor),
processor, // the original processor is wrapped in the mutex processor.
)
_, err = getProcessingError(err)
if err != nil {
Expand All @@ -589,6 +590,7 @@ func (t *localTraverser) prepareHashingThreads(preprocessor objectMorpher, proce
// wrap the processor, try to grab hashes, or defer processing to the goroutines
hashingProcessor = func(storedObject StoredObject) error {
if storedObject.entityType != common.EEntityType.File() {
// the original processor is wrapped in the mutex processor.
return processor(storedObject) // no process folders
}

Expand All @@ -603,6 +605,7 @@ func (t *localTraverser) prepareHashingThreads(preprocessor objectMorpher, proce
switch err {
case ErrorNoHashPresent, ErrorHashNoLongerValid, ErrorHashNotCompatible:
glcm.Info("No usable hash is present for " + fullPath + ". Will transfer if not present at destination.")
// the original processor is wrapped in the mutex processor.
return processor(storedObject) // There is no hash data, so this file will be overwritten (in theory).
case ErrorHashAsyncCalculation:
return nil // File will be processed later
Expand All @@ -620,7 +623,8 @@ func (t *localTraverser) prepareHashingThreads(preprocessor objectMorpher, proce
}

// delay the mutex until after potentially long-running operations
return mutexProcessor(processor)(storedObject)
// the original processor is wrapped in the mutex processor.
return processor(storedObject)
}

return finalizer, hashingProcessor
Expand Down