Skip to content

Commit

Permalink
Consistency for File State (#374)
Browse files Browse the repository at this point in the history
* Delete file immediately (not async) in CachePurge
* Make timeout minimum 1s
* Add lazy open state in flock, since it affects the whole file's state (not just one handle).
* Refactor isDownloadRequired, and use LazyOpen state variable to allow downloading when the file is lazy opened (but not completely opened).
* Refactor openFile
* Fix open handle count issue with Rename (by James)

---------

Co-authored-by: James Fantin-Hardesty <24646452+jfantinhardesty@users.noreply.github.com>
  • Loading branch information
foodprocessor and jfantinhardesty authored Jan 15, 2025
1 parent 5c33643 commit 3dbfd26
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 492 deletions.
2 changes: 2 additions & 0 deletions common/lock_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type LockMapItem struct {
exLocked bool
mtx sync.Mutex
downloadTime time.Time
// track if file is in lazy open state
LazyOpen bool
}

// Map holding locks for all the files
Expand Down
2 changes: 1 addition & 1 deletion component/azstorage/block_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func (bb *BlockBlob) List(prefix string, marker *string, count int32) ([]*intern
var dirList = make(map[string]bool)
for _, blobInfo := range listBlob.Segment.BlobItems {
blobInfo.Name = bb.getFileName(*blobInfo.Name)
attr := &internal.ObjAttr{}
var attr *internal.ObjAttr
if blobInfo.Properties.CustomerProvidedKeySHA256 != nil && *blobInfo.Properties.CustomerProvidedKeySHA256 != "" {
log.Trace("BlockBlob::List : blob is encrypted with customer provided key so fetching metadata explicitly using REST")
attr, err = bb.getAttrUsingRest(*blobInfo.Name)
Expand Down
4 changes: 2 additions & 2 deletions component/file_cache/cache_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ type cachePolicy interface {

UpdateConfig(cachePolicyConfig) error

CacheValid(name string) // Mark the file as hit
CachePurge(name string) // Schedule the file for deletion
CacheValid(name string) // Mark the file as hit
CachePurge(name string, flock *common.LockMapItem) // Delete the file from cache

IsCached(name string) bool // Whether or not the cache policy considers this file cached

Expand Down
Loading

0 comments on commit 3dbfd26

Please sign in to comment.