Skip to content

Commit 8997983

Browse files
committed
app/vlinsert/opentelemetry: properly clean log attribute to the underlying byte slice after parsing the EventName field at the LogRecord
Previously the old log attributes at fs.Fields could continue pointing to the underlying byte slice (the whole protobuf message received from the client) for long period of time after parsing the LogRecord.EventName field. This could result in excess memory usage. Fix this by properly cleaning all the references at fs.Fields after parsing the LogRecord.EventName field. Updates #869
1 parent bae626a commit 8997983

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/vlinsert/opentelemetry/pb.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,15 @@ func decodeScopeLogs(src []byte, fs *logstorage.Fields, fb *fmtBuffer, pushLogs
175175
pushLogs(timestamp, fs.Fields, streamFieldsLen+1)
176176

177177
// Return back common fields to their places before the next iteration
178+
fieldsLen := len(fs.Fields)
178179
fs.Fields = append(fs.Fields[:streamFieldsLen], fs.Fields[streamFieldsLen+1:commonFieldsLen+1]...)
180+
clear(fs.Fields[commonFieldsLen:fieldsLen])
179181
} else {
180182
pushLogs(timestamp, fs.Fields, streamFieldsLen)
181-
}
182183

183-
clear(fs.Fields[commonFieldsLen:])
184-
fs.Fields = fs.Fields[:commonFieldsLen]
184+
clear(fs.Fields[commonFieldsLen:])
185+
fs.Fields = fs.Fields[:commonFieldsLen]
186+
}
185187

186188
fb.buf = fb.buf[:fbLen]
187189
}

docs/victorialogs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ according to the follosing docs:
2525

2626
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly handle `null` values inside arrays. Previously, such arrays could cause a panic during ingestion. See [#869](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3627177567). The issue has been introduced in [v1.40.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0).
2727
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly skip attributes with missing key. See [this report](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3631307996).
28+
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): reduce memory usage after [v1.40.0 release](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0). See [#869](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869).
2829

2930
## [v1.40.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0)
3031

0 commit comments

Comments
 (0)