Haruki Okada created KAFKA-19334:
------------------------------------
Summary: 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
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)