You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Nuno Santos (Jira)" <ji...@apache.org> on 2026/10/13 09:36:00 UTC
[jira] [Resolved] (OAK-12450) Concurrency and memory-retention issues in ThreadSpecificSegmentBufferWriterPool
[ https://issues.apache.org/jira/browse/OAK-12450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nuno Santos resolved OAK-12450.
-------------------------------
Fix Version/s: 2.8.0
Resolution: Fixed
> 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: Nuno Santos
> Priority: Major
> Fix For: 2.8.0
>
>
> {{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)