Re: Problem with reading data from standby server ?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Condor <condor(at)stz-bg(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with reading data from standby server ?
Date: 2012-04-20 08:48:55
Message-ID: 4F9122F7.1010501@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20/04/12 09:39, Condor wrote:
> Hello,
>
> when I read binary replication tutorial
> (http://wiki.postgresql.org/wiki/Binary_Replication_Tutorial) I see on
> Hot Standby: Hot Standby is identical to Warm Standby, except that the
> Standby is available to run read-only queries.
> I setup hot standby server described in tutorial and it's working fine,
> no problem with that.

> I have a problem when I try to start a script that
> should read whole table, error message from php is:

> PHP Warning: pg_query(): Query failed: ERROR: canceling statement due to
> conflict with recovery

> When data is fetched it's saved into a file after some modifications.
> This script is work a 30-40 min until all data is parsed. Well, I think
> problem is started when master server send new wal file to slave, but
> how I can resolve that problem ?

Your master database is being updated all the time and your slave is
supposed to be a perfect copy, including deleted/updated rows being no
longer visible. So - when you run a query it might need to do one of two
things:
1. Pause replication
2. Cancel the query

At some point PostgreSQL switches from doing #1 to doing #2 (otherwise
you could get so far behind the replica could never catch up). You can
control how long before it switches:

http://www.postgresql.org/docs/9.1/static/hot-standby.html#HOT-STANDBY-CONFLICT

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2012-04-20 08:51:08 Re: Money in numeric field
Previous Message Condor 2012-04-20 08:39:25 Problem with reading data from standby server ?