title: How to exit out of database recovery mode (currently locked in read-only mode)
body: <p>A slave database was set up some time ago for the purpose of backing up or replicating a remote database. However I can no longer write to the database using a Delphi based ETL (the ETL works for another database pair, but to date has never been used for this particular pair). The replication database was setup by somebody else who has since left the company. I am reasonably sure this has been setup as a replication database, however the employee who has since left told me that replication never worked for unrelated reasons. Using the ETL we can (using SQL queries) read from the one database, and write back to the replication database, Or should be able to, as it is currently read only.</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>Maintenance such as <code>VACUUM</code></li>
  <li>Attempt to drop tables and the entire database</li>
  <li>Restore a full backup from the master database</li>
  </ol>
  
  <p>None of these work, and I am told the database is read-only.</p>
  
  <p>I have looked at <code>postgresql.conf</code> and see that <code>hot_standby</code> is checked, so I think (but am not 100% certain) that the database is in some sort of replication mode (I've never touched replication as supported by Postgres, so I wouldn't know).</p>
  
  <p>I have checked permissions in <code>pg_hba.conf</code> and see there are some credentials in there for replication. I am not sure whether this activates "replication mode" for the database, or simply means these credentials are for replication only.</p>
  
  <p>I have been through months worth of log files (This has not been working since our IT department upgraded the entire network about 5 months ago). I see the log file contents seen below, repeated over and over with nothing else for months. Note the IP address shown below is listed in the <code>pg_hba.conf</code> file, so credentials are valid.</p>
  
  <p>The database is in recovery mode, as I have found by using:</p>
  
  <pre><code>select pg_is_in_recovery();
  </code></pre>
  
  <p>This explains to me why it's read only, but why can I not restore databases, or just simply dump the entire database and start again (it's a backup so losing/restoring it is not an issue)?</p>
  
  <p>I was tempted to try modifying the <code>recovery.conf</code> file (which exists) but I read/believe that once recovery has been initiated (which in my case it has) modifying the file will have no effect.</p>
  
  <p>I'm using a legacy version of Postgres: 9.2.9</p>
  
  <p>Any help here would be greatly appreciated, as I have been working solidly on this for more than a day now.</p>
  
  <p>Log File entry (sample):</p>
  
  <pre><code>FATAL:  could not connect to the primary server:
  FATAL:  no pg_hba.conf entry for replication connection from host "192.168.20.2", user "postgres", SSL off
  
  FATAL:  could not connect to the primary server: server closed the connection unexpectedly
          This probably means the server terminated abnormally before or while processing the request.
  </code></pre>
  
  <p>A couple of options would work for me:</p>
  
  <ol>
  <li>Convert the database from being a read-only replication database, to a standard read/write database or</li>
  <li>Dump/drop the entire database so I can create a new one with write capabilities.</li>
  </ol>