The GitHub Actions job "Build" on jackrabbit-oak.git/issue/OAK-12450 has failed. Run started by GitHub user lweitzendorf (triggered by nfsantos).
Head commit for run: 46c5bcccefc719647eb51a6404c3fdf39b39ac77 / Lucas Weitzendorf <[email protected]> OAK-12450: Harden ThreadSpecificSegmentBufferWriterPool Hardens `ThreadSpecificSegmentBufferWriterPool` in `oak-segment-tar`. Review surfaced two concurrency defects plus a memory-retention issue in the read/write-lock based pool used on the segment write path. ### Changes - **Read-lock leak (correctness).** `execute()` obtained the per-thread writer *before* the `try`, so an exception while creating the writer (e.g. inside `computeIfAbsent` / `newWriter`) leaked the read lock and would block a later `flush()` (write lock) forever. The writer is now fetched inside the `try/finally`. - **`writerId` data race (correctness).** `writerId` was a plain `short` mutated with `++`. In the thread-specific pool, `newWriter` runs inside `computeIfAbsent`'s mapping function, which `ConcurrentHashMap` can invoke concurrently for distinct keys — an unsynchronized read-modify-write that can lose updates or produce duplicate writer ids. Now an `AtomicInteger` with a bounded `getAndUpdate`. - **Dead-thread pinning (memory).** The pool was keyed by the `Thread` object, holding it (and its `ThreadLocal`s) alive until the next `flush()`. Now keyed by thread id, so dead threads are collectable immediately. Thread ids are unique among live threads, so concurrent `execute()` calls never share a writer; a recycled id simply reuses a dead thread's writer, which is safe. ### Not included Avoiding the per-call key/lambda allocation in `getWriter` is deferred pending profiling; the allocation is small relative to the lock acquire and the write operation itself. ### Testing `mvn test -pl oak-segment-tar -Dtest='SegmentBufferWriterPoolTest,SegmentBufferWriterPoolMonitorTest,SingleSegmentBufferWriterPoolTest'` — 19 tests pass. Module compiles clean under `--release 17`. Report URL: https://github.com/apache/jackrabbit-oak/actions/runs/37779057340 With regards, GitHub Actions via GitBox
