Skip to content

Commit

Permalink
Autodiscover memleak (#41748)
Browse files Browse the repository at this point in the history
* Create a clone to release source struct from mem

* Cleanup meta on stop events

* Add changelog entry

---------

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
  • Loading branch information
rsafonseca and mauri870 authored Jan 27, 2025
1 parent b8ce873 commit bb5032e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix a bug where log files are rotated on startup when interval is configured and rotateonstartup is disabled {issue}41894[41894] {pull}41895[41895]
- Fix setting unique registry for non beat receivers {issue}42288[42288] {pull}42292[42292]
- The Kafka output now drops events when there is an authorisation error {issue}42343[42343] {pull}42401[42401]
- Fix autodiscovery memory leak related to metadata of start events {pull}41748[41748]

*Auditbeat*

Expand Down
7 changes: 6 additions & 1 deletion libbeat/autodiscover/autodiscover.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ func (a *Autodiscover) handleStop(event bus.Event) bool {
updated = true
}

// Cleanup meta references for this eventID
for configHash := range a.configs[eventID] {
a.meta.Remove(configHash)
}

delete(a.configs, eventID)

return updated
Expand All @@ -304,7 +309,7 @@ func (a *Autodiscover) getMeta(event bus.Event) mapstr.M {
a.logger.Errorf("Got a wrong meta field for event %v", event)
return nil
}
return meta
return meta.Clone()
}

// getID returns the event "id" field string if present
Expand Down

0 comments on commit bb5032e

Please sign in to comment.