Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Prevent crash due to concurrent map access in Go plugin log processing #1284

Merged
merged 5 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pluginmanager/plugin_runner_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,26 @@ func (p *pluginv1Runner) ReceiveRawLog(log *pipeline.LogWithContext) {
}

func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) {
context := logGroup.Context
topic := logGroup.LogGroup.GetTopic()
context[ctxKeyTopic] = topic
for _, log := range logGroup.LogGroup.Logs {
if len(topic) > 0 {
log.Contents = append(log.Contents, &protocol.Log_Content{Key: tagKeyLogTopic, Value: topic})
}
// When UsingOldContentTag is set to false, the tag is now put into the context during cgo.
if !p.LogstoreConfig.GlobalConfig.UsingOldContentTag {
context := map[string]interface{}{}
for key, value := range logGroup.Context {
context[key] = value
}
context[ctxKeyTopic] = topic
context[ctxKeyTags] = logGroup.LogGroup.LogTags
p.ReceiveRawLog(&pipeline.LogWithContext{Log: log, Context: context})
} else {
context := map[string]interface{}{}
for key, value := range logGroup.Context {
context[key] = value
}
context[ctxKeyTopic] = topic
quzard marked this conversation as resolved.
Show resolved Hide resolved
for _, tag := range logGroup.LogGroup.LogTags {
log.Contents = append(log.Contents, &protocol.Log_Content{
Key: tagPrefix + tag.GetKey(),
Expand Down
Loading