QOS.ch JIRA

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • logback-classic
  • LBCLASSIC-289

ConcurrentModificationException when using MDC

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9.29
  • Fix Version/s: 0.9.30
  • Component/s: appender
  • Labels:
    None
  • Environment:
    Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)
    Darwin aden 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64

Description

In some rare cases in multithreaded environment MDC.put throws ConcurrentModificationException.

java.util.ConcurrentModificationException: null
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) ~[na:1.6.0_26]
        at java.util.HashMap$EntryIterator.next(HashMap.java:834) ~[na:1.6.0_26]
        at java.util.HashMap$EntryIterator.next(HashMap.java:832) ~[na:1.6.0_26]
        at java.util.HashMap.putAll(HashMap.java:523) ~[na:1.6.0_26]
        at ch.qos.logback.classic.util.LogbackMDCAdapter.duplicateAndInsertNewMap(LogbackMDCAdapter.java:69)
~[logback-classic-0.9.29.jar:na]
        at ch.qos.logback.classic.util.LogbackMDCAdapter.put(LogbackMDCAdapter.java:95)
~[logback-classic-0.9.29.jar:na]
        at org.slf4j.MDC.put(MDC.java:112) ~[slf4j-api-1.6.1.jar:1.6.1]

Issue Links

is duplicated by

Bug - A problem which impairs or prevents the functions of the product. LBCLASSIC-267 Intermittent ConcurrentModificationException in LoggingEvent.prepareForDeferredProcessing

  • Critical - Crashes, loss of data, severe memory leak.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Bug - A problem which impairs or prevents the functions of the product. LBCLASSIC-268 ConcurrentModificationException in LogbackMDCAdapter

  • Critical - Crashes, loss of data, severe memory leak.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Josh Oddman added a comment - 17/Sep/11 12:26 AM
another trace:

Caused by: java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
        at java.util.HashMap$EntryIterator.next(HashMap.java:834)
        at java.util.HashMap$EntryIterator.next(HashMap.java:832)
        at java.util.HashMap.putAll(HashMap.java:523)
        at ch.qos.logback.classic.util.LogbackMDCAdapter.duplicateAndInsertNewMap(LogbackMDCAdapter.java:69)
        at ch.qos.logback.classic.util.LogbackMDCAdapter.put(LogbackMDCAdapter.java:95)
        at org.slf4j.MDC.put(MDC.java:112)
        ....
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Show
Josh Oddman added a comment - 17/Sep/11 12:26 AM another trace: Caused by: java.util.ConcurrentModificationException         at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)         at java.util.HashMap$EntryIterator.next(HashMap.java:834)         at java.util.HashMap$EntryIterator.next(HashMap.java:832)         at java.util.HashMap.putAll(HashMap.java:523)         at ch.qos.logback.classic.util.LogbackMDCAdapter.duplicateAndInsertNewMap(LogbackMDCAdapter.java:69)         at ch.qos.logback.classic.util.LogbackMDCAdapter.put(LogbackMDCAdapter.java:95)         at org.slf4j.MDC.put(MDC.java:112)         ....        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)         at java.lang.Thread.run(Thread.java:662)
Hide
Permalink
Ceki Gulcu added a comment - 20/Sep/11 9:56 PM
Fixed in [1] . LogbackMDCAdapter now synchronizes over its thread local map. This prevents ConcurrentModificationException from occurring while a child thread copies the map from the parent. There should be very little contention due to the synchronization because unrelated threads use different maps and parent/child threads will use different maps after the first write operation performed by the child thread.

[1] http://github.com/ceki/logback/commit/7a2e02bca24
Show
Ceki Gulcu added a comment - 20/Sep/11 9:56 PM Fixed in [1] . LogbackMDCAdapter now synchronizes over its thread local map. This prevents ConcurrentModificationException from occurring while a child thread copies the map from the parent. There should be very little contention due to the synchronization because unrelated threads use different maps and parent/child threads will use different maps after the first write operation performed by the child thread. [1] http://github.com/ceki/logback/commit/7a2e02bca24

People

  • Assignee:
    Ceki Gulcu
    Reporter:
    Josh Oddman
Vote (0)
Watch (1)

Dates

  • Created:
    28/Aug/11 6:54 PM
    Updated:
    20/Sep/11 9:56 PM
    Resolved:
    20/Sep/11 9:56 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for logback. Try JIRA - bug tracking software for your team.