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

Closable processors are not really getting closed #34726

Closed
faec opened this issue Mar 2, 2023 · 2 comments
Closed

Closable processors are not really getting closed #34726

faec opened this issue Mar 2, 2023 · 2 comments
Labels
bug Team:Elastic-Agent Label for the Agent team

Comments

@faec
Copy link
Contributor

faec commented Mar 2, 2023

Some processors in libbeat have resources that need to be released when they're done. These processors implement the interface Closer in addition to the baseline Processor. However, it looks like the Close function is never getting called on such processors. This probably affects all Beats versions for at least the last ~2 years.

Here is the function that closes a processor, in libbeat/processors/processor.go:

// Close closes a processor if it implements the Closer interface
func Close(p Processor) error {
	if closer, ok := p.(Closer); ok {
		return closer.Close()
	}
	return nil
}

However, both Processor and Closer are interface types:

type Processor interface {
	Run(event *beat.Event) (*beat.Event, error)
	String() string
}

type Closer interface {
	Close() error
}

and interface casts like that only work if one interface is a refinement of the other, they do not check the underlying type. See for example this demonstration of the issue in a go playground. This probably means that the underlying struct for all closable processors is never receiving a Close call.

This is related to but independent from the recent error loops in #34716.

@faec faec added bug Team:Elastic-Agent Label for the Agent team labels Mar 2, 2023
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@faec
Copy link
Contributor Author

faec commented Mar 2, 2023

Ah! A mistake in my testing, disregard.

@faec faec closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

No branches or pull requests

2 participants