Postgres Flex cluster has no writable primary, all nodes are in recovery

Hi, our Postgres Flex cluster suddenly became read-only even though it had been working normally before.

Fly reports one machine as primary and the other two as replica, but PostgreSQL on all three machines returns:

pg_is_in_recovery() = true

All three machines also have the exact same replay LSN.

repmgrd logs contain:

unable to determine an active primary for this cluster

and:

current upstream node is not primary

There are also errors related to a missing replication slot:

replication slot "repmgr_slot_..." does not exist

Our application connects through the Flycast hostname on port 5432, but the connection is read-only.

The application now fails to start because PostgreSQL rejects writes with:

cannot execute UPDATE in a read-only transaction

The app itself had not changed before this happened.

Has anyone seen a Postgres Flex cluster end up with all nodes running as standbys while Fly still reports one of them as primary?

What is the safest way to restore a writable primary without risking data loss?

We have not deleted or recreated any machines or volumes

Thanks in advance

Resolved by promoting the machine shown as primary using this command
repmgr -f /data/repmgr.conf standby promote

Thanks