Skip to content

[bug] LogRecordSharedPool isn't thread safe #6233

@MarcCain-Scott

Description

@MarcCain-Scott

Package

OpenTelemetry

Package Version

Package Name Version
OpenTelemetry 1.11.2

Runtime Version

net8.0

Description

The Rent() method of LogRecordSharedPool is not thread safe and this causes the same LogRecord to be given out multiple times and then the data from one is overwritten or combined into a single log which then gets submitted twice.

Steps to Reproduce

I'm trying to come up with a unit test but there is such a small window that it is difficult. I can say in a full working system with many threads and logs that a small percentage of the logs are lost.

Expected Result

LogRecordSharedPool.Rent() should never return the same LogRecord no matter the load.

Actual Result

One log will be sent twice with a merge of attributes from two different logs and one Body will win. The ID is identical.

Additional Context

By forcing the use of the LogRecordThreadStaticPool this never happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedGood for taking. Extra help will be provided by maintainerspkg:OpenTelemetryIssues related to OpenTelemetry NuGet package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions