Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6jLc-0004HX-HY for pgsql-general@arkaria.postgresql.org; Tue, 06 Aug 2013 15:38:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V6jLb-0005WW-U2 for pgsql-general@arkaria.postgresql.org; Tue, 06 Aug 2013 15:38:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6Zu3-0003nz-Oa for pgsql-general@postgresql.org; Tue, 06 Aug 2013 05:33:52 +0000 Received: from mail-pb0-x22d.google.com ([2607:f8b0:400e:c01::22d]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6Zty-000156-Ub for pgsql-general@postgresql.org; Tue, 06 Aug 2013 05:33:51 +0000 Received: by mail-pb0-f45.google.com with SMTP id mc17so4284527pbc.32 for ; Mon, 05 Aug 2013 22:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :message-id:references:to; bh=6L9mTwnjdQBGjDXWeFWcoXb2j1WPZoEEX2X3tt2xAzI=; b=I/OgdBEmv60OE3LZVy6y6pt+DZs4+R4xmv4+V5sHufnI4Egk09HwQnSTxGfXgdEa0L Lp/bsurdvMUtTaqaqLRYHK43C8g0R7p3sNW1fnk+tMsLzGoLgbFmISECGTcgYd3W7IQM BYFOdG+P1ekWFIbWSDwG4Kl4b8WTUw8EmFgh/2c8uS/bc+U0s0xIY63pydpa7Rqbrr8q 84QnZBpKG8phcvm3zHdHmmgVg2QlrOmUa4hZ/3t2n6VbuaWVhhc2miQCXMRRcL1xh9ns 9bBCFuK6ioVi7QWON/qGVAb8UUUIZ5Ez89LhS6NDWkBwuBu0PpNnHc/glqBbY5rgnLBX UtwQ== X-Received: by 10.66.179.143 with SMTP id dg15mr1296638pac.52.1375767225338; Mon, 05 Aug 2013 22:33:45 -0700 (PDT) Received: from [192.168.0.102] (014136185055.ctinets.com. [14.136.185.55]) by mx.google.com with ESMTPSA id ep4sm2911533pbd.35.2013.08.05.22.33.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 Aug 2013 22:33:44 -0700 (PDT) Subject: Re: pg_stat_replication became empty suddenly Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: multipart/alternative; boundary=Apple-Mail-35-175546855 From: "ascot.moss@gmail.com" In-Reply-To: <57DC0F7E-C959-462D-874F-3EEA49702EC8@gmail.com> Date: Tue, 6 Aug 2013 13:33:41 +0800 Cc: ascot.moss@gmail.com Message-Id: <11FDD81A-072D-49DC-9B31-6023E5593023@gmail.com> References: <8810.1375247630@sss.pgh.pa.us> <2EB17B60-33A2-4855-A176-0E8DD16ED7E1@gmail.com> <10906.1375273486@sss.pgh.pa.us> <57DC0F7E-C959-462D-874F-3EEA49702EC8@gmail.com> To: PostgreSQL general X-Mailer: Apple Mail (2.1085) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org --Apple-Mail-35-175546855 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, I just tried another round of tests, without running "sync; echo 3 > = /proc/sys/vm/drop_caches', still got the same error, following FATAL errors are found in pg_log = (slave), can anyone please advise how to resolve this error? regards LOG: entering standby mode LOG: consistent recovery state reached at 11/42000318 LOG: redo starts at 11/42000280 LOG: invalid record length at 11/42000318 LOG: database system is ready to accept read only connections LOG: streaming replication successfully connected to primary FATAL: could not send data to WAL stream: server closed the connection = unexpectedly This probably means the server terminated abnormally before or while processing the request. =09 LOG: unexpected pageaddr 10/D2EC0000 in log file 18, segment 5, offset = 15466496 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed =09 LOG: streaming replication successfully connected to primary FATAL: could not receive data from WAL stream: FATAL: requested WAL = segment 000000010000001200000005 has already been removed On 6 Aug 2013, at 12:39 PM, ascot.moss@gmail.com wrote: > Hi, >=20 > I found the problem should be because I tried to clean RAM cache in = the slave by running "sync; echo 3 > /proc/sys/vm/drop_caches'=20 > that caused the "receiver" of slave gone away. >=20 > ps -ef | grep receiver > postgres 6182 6178 0 12:11 ? 00:00:06 postgres: wal = receiver process streaming D/FB8DA000 =20 > sync; echo 3 > /proc/sys/vm/drop_caches > ps -ef | grep receiver > root 8804 30447 0 12:29 pts/2 00:00:00 grep --color=3Dauto = receiver >=20 > regards >=20 > On 6 Aug 2013, at 10:44 AM, ascot.moss@gmail.com wrote: >=20 >> Hi, >>=20 >> I am doing some stress tests to a pair of PG servers to monitor the = pg_stat_replication, during the test, the pg_stat_replication suddenly = became empty.=20 >>=20 >> PG version: 9.2.4 >> O/S: Ubuntu: 12.04 >>=20 >> Since I need to monitor the replication lag from time to time, if the = pg_stat_replication becomes empty, the lag calculation in the slave will = be wrong. >> Please advise if this is a bug. >>=20 >> regards >>=20 >>=20 >>=20 >>=20 >> How to reproduce: >>=20 >> session 1: Master server - try to insert a large number of records = into a test table=20 >> postgres=3D# drop table test;CREATE TABLE test (id INTEGER PRIMARY = KEY); INSERT INTO test VALUES (generate_series(1,100000000)); EXPLAIN = ANALYZE SELECT COUNT(*) FROM test; >>=20 >> 2) session 2: Master server - check the byte_lag from time to time >> postgres=3D# SELECT >> sent_offset - ( >> replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS = byte_lag >> FROM ( >> SELECT >> client_addr, >> ('x' || lpad(split_part(sent_location, '/', 1), 8, = '0'))::bit(32)::bigint AS sent_xlog, >> ('x' || lpad(split_part(replay_location, '/', 1), 8, = '0'))::bit(32)::bigint AS replay_xlog, >> ('x' || lpad(split_part(sent_location, '/', 2), 8, = '0'))::bit(32)::bigint AS sent_offset, >> ('x' || lpad(split_part(replay_location, '/', 2), 8, = '0'))::bit(32)::bigint AS replay_offset >> FROM pg_stat_replication >> ) AS s; >> byte_lag=20 >> ---------- >> 2097216 >> (1 row) >>=20 >> postgres=3D# SELECT >>=20 >> sent_offset - ( >> replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS = byte_lag >> FROM ( >> SELECT >> client_addr, >> ('x' || lpad(split_part(sent_location, '/', 1), 8, = '0'))::bit(32)::bigint AS sent_xlog, >> ('x' || lpad(split_part(replay_location, '/', 1), 8, = '0'))::bit(32)::bigint AS replay_xlog, >> ('x' || lpad(split_part(sent_location, '/', 2), 8, = '0'))::bit(32)::bigint AS sent_offset, >> ('x' || lpad(split_part(replay_location, '/', 2), 8, = '0'))::bit(32)::bigint AS replay_offset >> FROM pg_stat_replication >> ) AS s; >> byte_lag=20 >> ---------- >> (0 rows) >>=20 >>=20 >> 3) session 3: Slave server -=20 >> postgres=3D# SELECT CASE WHEN pg_last_xlog_receive_location() =3D = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - = pg_last_xact_replay_timestamp()) END AS log_delay; >> log_delay=20 >> ----------- >> 0 >> (1 row) >>=20 >> postgres=3D# SELECT CASE WHEN pg_last_xlog_receive_location() =3D = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - = pg_last_xact_replay_timestamp()) END AS log_delay; >> log_delay=20 >> ----------- >> 4.873282 >> (1 row) >>=20 >> . >> . >> . >> postgres=3D# SELECT CASE WHEN pg_last_xlog_receive_location() =3D = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - = pg_last_xact_replay_timestamp()) END AS log_delay; >> log_delay =20 >> ------------- >> 4070.325329 >> (1 row) >>=20 >>=20 >=20 --Apple-Mail-35-175546855 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii sync; echo 3 = > /proc/sys/vm/drop_caches',
still got the same = error,  following FATAL errors are found in pg_log (slave), = can anyone please advise how to resolve this = error?

regards


=
LOG:  entering standby mode
LOG: =  consistent recovery state reached at 11/42000318
LOG: =  redo starts at 11/42000280
LOG:  invalid record = length at 11/42000318
LOG:  database system is ready to = accept read only connections
LOG:  streaming replication = successfully connected to primary
FATAL:  could not send = data to WAL stream: server closed the connection = unexpectedly
This probably means the = server terminated abnormally
before or while = processing the request.
LOG:  unexpected = pageaddr 10/D2EC0000 in log file 18, segment 5, offset = 15466496
LOG:  streaming replication successfully = connected to primary
FATAL:  could not receive data from = WAL stream: FATAL:  requested WAL segment 000000010000001200000005 = has already been removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed
LOG:  streaming = replication successfully connected to primary
FATAL: =  could not receive data from WAL stream: FATAL:  requested WAL = segment 000000010000001200000005 has already been = removed





On 6 Aug 2013, at 12:39 PM, ascot.moss@gmail.com = wrote:

Hi,

I = found the problem should be because I tried to clean RAM cache in the = slave by running "sync; echo 3 > = /proc/sys/vm/drop_caches' 
that caused the = "receiver" of slave gone away.

ps -ef | = grep receiver
postgres  6182  6178 =  0 12:11 ?        00:00:06 postgres: wal = receiver process   streaming D/FB8DA000   =  
sync; echo 3 = > /proc/sys/vm/drop_caches
ps -ef | grep = receiver
root      8804 30447  0 12:29 = pts/2    00:00:00 grep --color=3Dauto = receiver

regards

On= 6 Aug 2013, at 10:44 AM, ascot.moss@gmail.com = wrote:

Hi,

I = am doing some stress tests to a pair of PG servers to monitor = the pg_stat_replication, during the test, = the pg_stat_replication suddenly became = empty. 

PG version: 9.2.4
O/S: = Ubuntu: 12.04

Since I need to monitor the = replication lag from time to time, if the pg_stat_replication = becomes empty, the lag calculation in the slave will be = wrong.
Please advise if this is a = bug.

regards


<= div>

How to = reproduce:

session 1: Master server - try = to insert a large number of records into a test = table 
postgres=3D# drop table test;CREATE TABLE = test (id INTEGER PRIMARY KEY); INSERT INTO test VALUES = (generate_series(1,100000000));  EXPLAIN ANALYZE SELECT COUNT(*) = FROM test;

2) session 2: Master server - check = the byte_lag from time to time
postgres=3D# = SELECT
    sent_offset - (
    =     replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) = AS byte_lag
FROM (
    = SELECT
        = client_addr,
        ('x' || = lpad(split_part(sent_location,   '/', 1), 8, '0'))::bit(32)::bigint = AS sent_xlog,
        ('x' || = lpad(split_part(replay_location, '/', 1), 8, '0'))::bit(32)::bigint AS = replay_xlog,
        ('x' || = lpad(split_part(sent_location,   '/', 2), 8, '0'))::bit(32)::bigint = AS sent_offset,
        ('x' || = lpad(split_part(replay_location, '/', 2), 8, '0'))::bit(32)::bigint AS = replay_offset
    FROM = pg_stat_replication
) AS = s;
byte_lag 
----------
2097216
(1 row)

postgres=3D# = SELECT

    sent_offset - = (
        replay_offset - (sent_xlog - = replay_xlog) * 255 * 16 ^ 6 ) AS byte_lag
FROM = (
    SELECT
        = client_addr,
        ('x' || = lpad(split_part(sent_location,   '/', 1), 8, '0'))::bit(32)::bigint = AS sent_xlog,
        ('x' || = lpad(split_part(replay_location, '/', 1), 8, '0'))::bit(32)::bigint AS = replay_xlog,
        ('x' || = lpad(split_part(sent_location,   '/', 2), 8, '0'))::bit(32)::bigint = AS sent_offset,
        ('x' || = lpad(split_part(replay_location, '/', 2), 8, '0'))::bit(32)::bigint AS = replay_offset
    FROM = pg_stat_replication
) AS = s;
byte_lag 
----------
(0 = rows)


3) session 3: = Slave server - 
postgres=3D# SELECT CASE WHEN = pg_last_xlog_receive_location() =3D pg_last_xlog_replay_location() =  THEN 0 ELSE EXTRACT (EPOCH FROM now() - = pg_last_xact_replay_timestamp()) END AS = log_delay;
 log_delay 
-----------
         0
(1 = row)

postgres=3D# SELECT CASE WHEN = pg_last_xlog_receive_location() =3D pg_last_xlog_replay_location() =  THEN 0 ELSE EXTRACT (EPOCH FROM now() - = pg_last_xact_replay_timestamp()) END AS = log_delay;
 log_delay 
-----------
  4.873282
(1 = row)

.
.
.
postgres=3D# SELECT CASE WHEN pg_last_xlog_receive_location() =3D = pg_last_xlog_replay_location()  THEN 0 ELSE EXTRACT (EPOCH FROM = now() - pg_last_xact_replay_timestamp()) END AS = log_delay;
  log_delay =  
-------------
 4070.325329
(1 = row)



= --Apple-Mail-35-175546855--