You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "TengYao Chi (Jira)" <ji...@apache.org> on 2025/06/09 04:55:00 UTC
[jira] [Commented] (KAFKA-19334) MetadataShell bypasses file lock unexpectedly due to lock file deletion
[ https://issues.apache.org/jira/browse/KAFKA-19334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956815#comment-17956815 ]
TengYao Chi commented on KAFKA-19334:
-------------------------------------
Cherry pick to 3.9 and 4.0
> MetadataShell bypasses file lock unexpectedly due to lock file deletion
> -----------------------------------------------------------------------
>
> Key: KAFKA-19334
> URL: https://issues.apache.org/jira/browse/KAFKA-19334
> Project: Kafka
> Issue Type: Bug
> Affects Versions: 4.0.0
> Reporter: Haruki Okada
> Assignee: Haruki Okada
> Priority: Major
> Fix For: 3.9.2, 4.0.1, 4.1.0
>
>
> MetadataShell acquires log dir lock to prevent unexpected results by concurrent reads/writes fixed by [https://github.com/apache/kafka/pull/14899].
>
> This lock works as expected when we execute MetadataShell against running log for the first time:
>
> {code:java}
> % ./bin/kafka-metadata-shell.sh --snapshot data/bootstrap.checkpoint
> Unexpected error: Unable to lock /path/to/data. Please ensure that no broker or controller process is using this directory before proceeding.{code}
> However, if we execute MetadataShell with same command again with controller still running, it succeeds unexpectedly.
>
>
> {code:java}
> % ./bin/kafka-metadata-shell.sh --snapshot data/bootstrap.checkpoint
> Loading...
> Starting...
> [ Kafka Metadata Shell ]
> >> {code}
> And I found that .lock file vanishes after MetadataShell exit.
>
> This is because MetadataShell calls FileLock#destroy when it fails acquiring lock, which deletes the lock file.
> [https://github.com/apache/kafka/blob/4.0.0/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java#L131]
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)