# Using Cooperative Locking for HA with MaxScale's MariaDB Monitor

MaxScale's [MariaDB Monitor (mariadbmon)](/docs/maxscale/maxscale-archive/archive/mariadb-maxscale-23-02/mariadb-maxscale-23-02-monitors/mariadb-maxscale-2302-mariadb-monitor.md) monitors [MariaDB replication](/docs/server/ha-and-performance/standard-replication.md) deployments.

When multiple MaxScale instances are used in a highly available deployment, MariaDB Monitor needs to ensure that only one MaxScale instance performs [automatic failover](/docs/maxscale/maxscale-archive/archive/mariadb-maxscale-21-06/mariadb-maxscale-2106-maxscale-21-06-monitors/maxscale-mariadb-monitor-usage/maxscale-mariadb-monitor-usage-mariadb-monitor/using-automatic-failover-with-maxscales-mariadb-monitor.md) operations at a given time. It does this by using cooperative locks on the back-end servers.

## How MariaDB Monitor uses Cooperative Locks

When cooperative locking is enabled for MariaDB Monitor, it tries to acquire locks on the back-end servers with [GET\_LOCK()](/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock.md) function. If a specific MaxScale instance is able to acquire the lock on a majority of servers, then it is considered the primary MaxScale instance, which means that it can handle [automatic failover](/docs/maxscale/maxscale-archive/archive/mariadb-maxscale-21-06/mariadb-maxscale-2106-maxscale-21-06-monitors/maxscale-mariadb-monitor-usage/maxscale-mariadb-monitor-usage-mariadb-monitor/using-automatic-failover-with-maxscales-mariadb-monitor.md).

## Configuring Cooperative Locking

1. Configure cooperative locking by configuring the `cooperative_monitoring_locks` parameter for the MariaDB Monitor in `maxscale.cnf.` It has several possible values.

| Value                 | Description                                                                         |
| --------------------- | ----------------------------------------------------------------------------------- |
| none                  | Do not use any cooperative locking. This is the default value.                      |
| majority\_of\_all     | Primary monitor requires locks on a majority of servers, even those which are down. |
| majority\_of\_running | Primary monitor requires locks on a majority of running servers.                    |

For example:

```
[repl-cluster]
type                     = monitor
module                   = mariadbmon
...
cooperative_monitoring_locks = majority_of_running
```

2. Restart the MaxScale instance.

```
$ sudo systemctl restart maxscale
```

<sub>*This page is: Copyright © 2025 MariaDB. All rights reserved.*</sub>

{% @marketo/form formId="4316" %}


---

# 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://mariadb.com/docs/maxscale/maxscale-archive/archive/mariadb-maxscale-21-06/mariadb-maxscale-2106-maxscale-21-06-monitors/maxscale-mariadb-monitor-usage/maxscale-mariadb-monitor-usage-mariadb-monitor/using-cooperative-locking-for-ha-with-maxscales-mariadb-monitor.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.
