Skip to content

Context data is lost if AsyncLogger and AsyncLoggerConfig are both used #1786

Closed
@ppkarwasz

Description

@ppkarwasz

Description

If the user uses both an AsyncLoggerContext (which makes all loggers to be of type AsyncLogger) and AsyncLoggerConfig, a race condition can occur, which causes context data to be lost.

Details

If both AsyncLogger and AsyncLoggerConfig are used together (which is no advised, but possible and there is a test for it):

  • AsyncLoggerConfig#log is called from the main disruptor thread with a RingBufferLogEvent argument,
  • AsyncLoggerConfig calls RingBufferLogEvent#createMemento() before sending the event to its own disruptor thread. However this method does not make a copy of the context data, nor does it mark the data as "frozen",
  • A RingBufferLogEvent#clear() on the main disruptor thread clears the context data. If the disruptor thread of AsyncLoggerConfig didn't log the message yet, it will log it without context data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect, unexpected, or unintended behavior of existing code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions