You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deterministically close open span cache file descriptors
The snapshotter stores fetched spans in a cache either in memory
or on disk. When reading from the cache on disk we use a Finalizer
construct to close the open file descriptors when the Go garbage
collector sees that the fd is no longer being referenced. The issue with
this is that we don't have control over when the GC runs (although it's
possible), and so the process could hold on too open fds for a unknown
amount of time causing a sort of leak. On systems where the snapshotter is
bounded by a ulimit in the number of open files, this can cause the
snapshotter span cache get calls to fail, causing `file.Read` failures for the
running container/process. This change wraps the readers returned by the
cache in `io.ReadCloser`'s, so we can deterministically close the files
once the content has been read from them.
Signed-off-by: Yasin Turan <[email protected]>
return0, fmt.Errorf("failed to read the file: %w", err)
227
227
}
228
+
deferr.Close()
228
229
229
230
// TODO this is not the right place for this metric to be. It needs to go down the BlobReader, when the HTTP request is issued
230
231
commonmetrics.IncOperationCount(commonmetrics.SynchronousReadRegistryFetchCount, sf.gr.layerSha) // increment the number of on demand file fetches from remote registry
0 commit comments