[
https://issues.apache.org/jira/browse/OAK-12450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Reschke reassigned OAK-12450:
------------------------------------
Assignee: Julian Reschke
> Concurrency and memory-retention issues in
> ThreadSpecificSegmentBufferWriterPool
> --------------------------------------------------------------------------------
>
> Key: OAK-12450
> URL: https://issues.apache.org/jira/browse/OAK-12450
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: segment-tar
> Reporter: Lucas Weitzendorf
> Assignee: Julian Reschke
> Priority: Major
>
> {{ThreadSpecificSegmentBufferWriterPool}} has three problems:
> * *Read lock leak:* {{execute()}} gets the per-thread writer before entering
> {{try/finally}}. If creating the writer throws, the read lock is never
> released, and a later {{flush()}} (which takes the write lock) blocks forever.
> * *Data race on {{writerId}}:* {{writerId}} is a plain {{short}} incremented
> with {{++}} inside {{computeIfAbsent}}'s mapping function. That function can
> run concurrently for different keys, so updates can be lost and writer IDs
> can be duplicated.
> * *Dead threads kept alive:* the pool is keyed by {{Thread}}, so it holds
> terminated threads and their {{ThreadLocal}}s until the next {{flush()}}.
> Fix: get the writer inside {{try/finally}}, use an {{AtomicInteger}} with a
> bounded {{getAndUpdate}} for writer IDs, and key the pool by thread ID
> instead of {{Thread}}. Tests are added in {{SegmentBufferWriterPoolTest}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)