Skip to content

Commit

Permalink
Merge branch 'fix-race-conditions' into delete-files-synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
foodprocessor committed Nov 27, 2024
2 parents f810edf + 2ea9b61 commit 74e3769
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions component/file_cache/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1328,11 +1328,7 @@ func (fc *FileCache) GetAttr(options internal.GetAttrOptions) (*internal.ObjAttr

// To cover cases 2 and 3, grab the attributes from the local cache
localPath := filepath.Join(fc.tmpPath, options.Name)
flock := fc.fileLocks.Get(options.Name)
// TODO: should we use a RWMutex and use RLock for stat calls?
flock.Lock()
info, err := os.Stat(localPath)
flock.Unlock()
// All directory operations are guaranteed to be synced with storage so they cannot be in a case 2 or 3 state.
if err == nil && !info.IsDir() {
if exists { // Case 3 (file in cloud storage and in local cache) so update the relevant attributes
Expand Down
7 changes: 1 addition & 6 deletions component/file_cache/file_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,12 +1188,7 @@ func (suite *fileCacheTestSuite) TestGetAttrCase3() {
suite.assert.NoError(err)
suite.assert.NotNil(attr)
suite.assert.EqualValues(file, attr.Path)
// this check is flaky in our CI pipeline on Linux, so skip it
if runtime.GOOS != "windows" {
fmt.Println("Skipping TestGetAttrCase3 attr.Size check on Linux because it's flaky.")
} else {
suite.assert.EqualValues(1024, attr.Size)
}
suite.assert.EqualValues(1024, attr.Size)
}

func (suite *fileCacheTestSuite) TestGetAttrCase4() {
Expand Down

0 comments on commit 74e3769

Please sign in to comment.