conduktor.io ↗

Kafka Exception LockException

org.apache.kafka.streams.errors.LockException
Non-retriable Streams

Indicates that the state store directory lock could not be acquired because another thread holds the lock.

Common Causes

Solutions

Example Stack Trace

org.apache.kafka.streams.errors.LockException: stream-thread [my-app-StreamThread-1] standby-task [0_18] Failed to lock the state directory: /opt/kafka-streams/my-app/0_18 at org.apache.kafka.streams.processor.internals.StateDirectory.lock(StateDirectory.java:213) at org.apache.kafka.streams.processor.internals.ProcessorStateManager.<init>(ProcessorStateManager.java:122) at org.apache.kafka.streams.processor.internals.StreamTask.<init>(StreamTask.java:188) at org.apache.kafka.streams.processor.internals.ActiveTaskCreator.createTask(ActiveTaskCreator.java:124) at org.apache.kafka.streams.processor.internals.TaskManager.handleAssignment(TaskManager.java:288) at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:778) Caused by: org.rocksdb.RocksDBException: IO error: lock /opt/kafka-streams/my-app/0_18/LOCK: No locks available

Diagnostic Commands

ls -la <state.dir>/<application.id>/*/.lock # find which task dirs hold locks; lsof on the .lock file shows the owning PID kafka-streams-application-reset.sh --application-id <app-id> --bootstrap-server <b>:9092 --input-topics <topics> # after a full stop, clears local state so locks are recreated cleanly lsof +D <state.dir> # on Linux, list every process/file handle still open under the state directory

Related

Related Streams exceptions: BrokerNotFoundException · InternalTopicsAlreadySetupException · InvalidStateStoreException · InvalidStateStorePartitionException · MisconfiguredInternalTopicException · MissingInternalTopicsException · MissingSourceTopicException · ProcessorStateException

Hitting LockException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.