NodeEnvironment.assertEnvIsLocked threw The device is not ready

ES is deployed on an Azure VMSS (Windows VMs). It's throwing "The device is not ready" on some VMs when creating shards, while working well on some other VMs at the same time.

Here is what the exception looks like:

TraceLevel="WARN" ComponentName="default" Message="[2023-11-27T21:24:34,775][WARN ][org.elasticsearch.env.NodeEnvironment] lock assertion failed The device is not ready
	at Method)
	at org.elasticsearch.env.NodeEnvironment.assertEnvIsLocked(
	at org.elasticsearch.env.NodeEnvironment.nodePaths(
	at org.elasticsearch.monitor.fs.FsProbe.stats(
	at org.elasticsearch.monitor.fs.FsService.stats(
	at org.elasticsearch.monitor.fs.FsService.access$200(
	at org.elasticsearch.monitor.fs.FsService$FsInfoCache.refresh(
	at org.elasticsearch.monitor.fs.FsService$FsInfoCache.refresh(
	at org.elasticsearch.common.util.SingleObjectCache.getOrRefresh(
	at org.elasticsearch.monitor.fs.FsService.stats(
	at org.elasticsearch.node.NodeService.stats(
	at org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction.nodeOperation(
	at org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction.nodeOperation(
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(
	at org.elasticsearch.transport.TcpTransport$RequestHandler.doRun(
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

All the VMs have identical configurations. When I RDP to the VM, I can see "node.lock" file in "K:\esdata\nodes\0", where it's supposed to be. The device seems to be ready to me - I can create other files in above folder and can even move "node.lock" file to another folder and back.
(K: is a data disk associated with that VM exclusively, not a shared location.)

Restarting VM can solve the problem in most of the cases, but it will occur again after some time.

What could be the root cause and how should I fix it?

This exception is coming directly from the OS, and is not something Elasticsearch can work around. You'll need to speak to your infra people, or Azure support, to work out why it's happening.

Thank you, David!

I wrote some java code to simulate the situation. The code does below things:

  1. When it starts, create a file "node1.lock" and lock it with and tryLock(). The implementation is same as what Lucene's NativeFSLockFactory does here:
  2. After 0-120 seconds (random, to simulate the frequency of shard creation in our case), it will
    a. Get file size of node1.lock with FileChannel.size(). This is same as what Lucene's NativeFSLockFactory does here:
    b. Create a file "node2.lock" and lock it with and tryLock(). The implementation is same as what Lucene's NativeFSLockFactory does.
    c. Get file size of node2.lock with FileChannel.size(). Again, the implementation is same as what Lucene's NativeFSLockFactory does.
  3. Repeat step 2 indefinitely.

In other words, the code will create and keep a "permanent" file channel/lock and get the file size every 0-120 seconds. It will also create a transient file channel/lock, get the file size, and then release lock and delete the file every 0-120 seconds.

I put above code on 9 Azure VMs and ran it for 2 days. This morning I finally got a repro of the " The device is not ready" issue on one of those 9 vms. And the IOException was thrown by the "permanent" part. The transient file creation and lock part is still working well at the same time.

Is it expected that elasticsearch will keep the file channel and lock of "node.lock" for a long time?

Yes, that's expected.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.