Fixed runaway rolodex.

The rolodex was running away and locking up vacuum.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2024-01-31 15:15:24 -08:00
parent c55527066a
commit a24c05036b
4 changed files with 13 additions and 2 deletions

View File

@@ -108,7 +108,7 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
}
// check for circular references
if config.Logger != nil {
config.Logger.Debug("indexing rolodex")
config.Logger.Debug("checking for circular references")
}
now = time.Now()
if !config.SkipCircularReferenceCheck {

View File

@@ -58,7 +58,7 @@ func FindComponent(root *yaml.Node, componentId, absoluteFilePath string, index
friendlySearch = "$"
}
path, err := yamlpath.NewPath(friendlySearch)
if path == nil || err != nil {
if path == nil || err != nil || root == nil {
return nil // no component found
}
res, _ := path.Find(root)

View File

@@ -108,6 +108,7 @@ func (l *LocalFS) Open(name string) (fs.File, error) {
extractedFile, extErr = l.extractFile(name)
if extErr != nil {
l.processingFiles.Delete(name)
processingWaiter.done = true
return nil, extErr
}
if extractedFile != nil {
@@ -152,6 +153,10 @@ func (l *LocalFS) Open(name string) (fs.File, error) {
}
}
}
waiter, _ := l.processingFiles.Load(name)
if waiter != nil {
waiter.(*waiterLocal).done = true
}
l.processingFiles.Delete(name)
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}

View File

@@ -284,6 +284,11 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
"AllowRemoteLookup to true as part of the index configuration", remoteURL)
}
if !strings.HasPrefix(remoteURL, "http") {
i.logger.Debug("[rolodex remote loader] not a remote file, ignoring", "file", remoteURL)
return nil, nil
}
remoteParsedURL, err := url.Parse(remoteURL)
if err != nil {
return nil, err
@@ -306,6 +311,7 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
"remoteURL", remoteParsedURL.String())
for !wait.done {
i.logger.Debug("[rolodex remote loader] sleeping, waiting for file to return", "file", remoteURL)
time.Sleep(500 * time.Nanosecond) // breathe for a few nanoseconds.
}