# Instance in ERROR State, Write Lock on Disk File

## Problem

The OpenStack instance fails to start and goes in **ERROR** state because of a write lock on the disk file of the instance. The following error can be seen in the *ostackhost.log* **.**

{% tabs %}
{% tab title="None" %}

```none
561 TRACE oslo_messaging.rpc.server libvirtError: internal error: qemu unexpectedly closed the monitor: XXXX-XX-XXTXX:XX:XX.084234Z qemu-kvm: -drive file=/mnt/nfs/instances/0e4d3940-d7c7-410f-b3f1-72ffda4d5605/disk,format=qcow2,if=none,id=drive-virtio-disk0,cache=none: Failed to get "write" lock
```

{% endtab %}
{% endtabs %}

## Environment

* Platform9 Managed OpenStack - v3.6.0 and Higher

## Cause

Another process on the host is performing I/O operations on the disk file which causes the instance to fail during the start process as it cannot get a write-lock on the disk file.

## Resolution

1. Check the hostname for the OpenStack instance.

{% tabs %}
{% tab title="None" %}

```none
# [root@testregion.platform9.net user(admin)]# openstack server show 0e4d3940-d7c7-410f-b3f1-72ffda4d5605+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+| Field                              | Value                                                                                                                                                |+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+| OS-DCF:diskConfig                  | MANUAL                                                                                                                                                || OS-EXT-AZ:availability_zone        | HA-Win                                                                                                                                                || OS-EXT-PF9-SRV-RES-INFO:res_info    | {u'cfg_disk_gb': 60.0, u'vcpus': 6, u'cfg_memory_mb': 32768, u'cpu_mhz': 1000}                                                                        || OS-EXT-SRV-ATTR:host                | c4f909eb-56c4-41b2-a0a5-ccef71af8d71                                                                                                                  || OS-EXT-SRV-ATTR:hypervisor_hostname | demohost01                                                                                                                            || OS-EXT-SRV-ATTR:instance_name      | 0e4d3940-d7c7-410f-b3f1-72ffda4d5605                                                                                                                  || OS-EXT-STS:fault                    | {u'message': u'Instance 0e4d3940-d7c7-410f-b3f1-72ffda4d5605 could not be found on hypervisor.', u'code': 94043, u'details': u''}                    |                                                                                                    | OS-EXT-STS:vm_state                | error
```

{% endtab %}
{% endtabs %}

2. Log in to the host on which the instance resides.
3. Navigate to the disk file location mentioned in the *ostackhost.log* error.

{% tabs %}
{% tab title="None" %}

```none
561 TRACE oslo_messaging.rpc.server libvirtError: internal error: qemu unexpectedly closed the monitor: XXXX-XX-XXTXX:XX:XX.084234Z qemu-kvm: -drive file=/mnt/nfs/instances/0e4d3940-d7c7-410f-b3f1-72ffda4d5605/disk,format=qcow2,if=none,id=drive-virtio-disk0,cache=none: Failed to get "write" lock
```

{% endtab %}
{% endtabs %}

4. Create a backup copy of the original disk file in the same directory.

{% tabs %}
{% tab title="None" %}

```none
# cp disk disk.bak
```

{% endtab %}
{% endtabs %}

5. Rename the original disk to **disk.old**.

{% tabs %}
{% tab title="None" %}

```none
# mv disk disk.old
```

{% endtab %}
{% endtabs %}

6. Rename the backup disk to disk.

{% tabs %}
{% tab title="None" %}

```none
# mv disk.bak disk
```

{% endtab %}
{% endtabs %}

7. Set the instance status to active.

{% tabs %}
{% tab title="None" %}

```none
# openstack server set --state active [instance-id]
```

{% endtab %}
{% endtabs %}

8. Stop the server.

{% tabs %}
{% tab title="None" %}

```none
# openstack server stop [instance-id]
```

{% endtab %}
{% endtabs %}

9. Start the server.

{% tabs %}
{% tab title="None" %}

```none
# openstack instance start [instance-id]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmo/solution/instance-in-error-state-write-lock-on-disk-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
