[ https://issues.apache.org/jira/browse/KAFKA-19334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17954105#comment-17954105 ]
Haruki Okada commented on KAFKA-19334: -------------------------------------- [~cmccabe] Submitted a patch for this. Could you take a look? > 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 > > 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)