diff --git a/.chloggen/batcher-bug-workers.yaml b/.chloggen/batcher-bug-workers.yaml new file mode 100644 index 000000000000..5b1d52d9f47a --- /dev/null +++ b/.chloggen/batcher-bug-workers.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: exporterhelper + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Prevent uncontrolled goroutines in batcher due to a incorrect worker pool behaviour. + +# One or more tracking issues or pull requests related to the change +issues: [13689] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/exporter/exporterhelper/internal/queuebatch/partition_batcher.go b/exporter/exporterhelper/internal/queuebatch/partition_batcher.go index bedf07bf2211..7ee88e8b6fd8 100644 --- a/exporter/exporterhelper/internal/queuebatch/partition_batcher.go +++ b/exporter/exporterhelper/internal/queuebatch/partition_batcher.go @@ -261,8 +261,12 @@ func newWorkerPool(maxWorkers int) *workerPool { func (wp *workerPool) execute(f func()) { <-wp.workers - go f() - wp.workers <- struct{}{} + go func() { + defer func() { + wp.workers <- struct{}{} + }() + f() + }() } type multiDone []queue.Done