[
https://issues.apache.org/jira/browse/CASSANDRA-21616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112025#comment-18112025
]
Michael Semb Wever edited comment on CASSANDRA-21616 at 9/6/26 8:40 AM:
------------------------------------------------------------------------
CI:
- 5.0 https://astro-cass.ci/job/cassandra-5.0/17/
- 6.0 https://astro-cass.ci/job/cassandra-6.0/18/
- trunk https://astro-cass.ci/job/cassandra/22/
was (Author: michaelsembwever):
CI:
- 5.0 https://astro-cass.ci/job/cassandra-5.0/17/
- 6.0 https://astro-cass.ci/job/cassandra-6.0/
- trunk https://astro-cass.ci/job/cassandra/22/
> The commit log allocator never observes the shutdown state, so a prepared
> segment can leak
> ------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-21616
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21616
> Project: Apache Cassandra
> Issue Type: Bug
> Components: Local/Commit Log
> Reporter: Michael Semb Wever
> Assignee: Michael Semb Wever
> Priority: Normal
> Fix For: 5.0.x, 6.0.x, 7.x
>
>
> {{AbstractCommitLogSegmentManager.shutdown}} calls
> {{executor.shutdownNow()}}, which puts the {{InfiniteLoopExecutor}} into
> {{SHUTTING_DOWN_NOW}}. {{InfiniteLoopExecutor.loop}} tests that state at the
> top of the loop and breaks before it runs the task:
> {code:java}
> Object cur = state;
> if (cur == SHUTTING_DOWN_NOW) break;
> interrupted |= Thread.interrupted();
> if (cur == NORMAL && interrupted) cur = INTERRUPTED;
> task.run((State) cur);
> {code}
> So {{AllocatorRunnable}} never receives
> {{Interruptible.State.SHUTTING_DOWN}}, and this branch of it is unreachable:
> {code:java}
> case SHUTTING_DOWN:
> // If shutdown() started and finished during segment creation, we are now
> left with a
> // segment that no one will consume. Discard it.
> discardAvailableSegment();
> return;
> {code}
> The branch guards a real interleaving. A shutdown that starts while the
> allocator sits between the state test and the segment creation block finds no
> available segment to discard. The allocator then clears the interrupt,
> creates a segment and assigns it, and the loop breaks on the next pass.
> Nothing consumes that segment and nothing discards it, so its file stays in
> the commit log directory and its buffer is not released. {{awaitTermination}}
> only closes the segments in {{activeSegments}}.
> CASSANDRA-16925 introduced the condition when it moved the allocator onto
> {{Interruptible}}. The code it replaced held a {{shutdown}} flag that the
> allocator tested straight after {{createSegment}}, in the same loop pass, so
> the discard ran.
> The patch calls {{executor.shutdown()}}, which delivers one final
> {{SHUTTING_DOWN}} pass to the task and restores the discard.
> Patch:
> [mck/CASSANDRA-21616/5.0|https://github.com/thelastpickle/cassandra/tree/mck/CASSANDRA-21616/5.0]
> Provenance:
> [1976b540ca|https://github.com/datastax/cassandra/commit/1976b540ca8e63205f6d8a56aa0c7f4a6b2112e9]
> by [~brandon.williams]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]