pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Alexey Klyukin <alexk@hintbits.com>
Cc: christian.echerer@manroland-web.com, András Váczi <avandras@gmail.com>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: Missing timeline history file after execution of pg_upgrade
Date: Thu, 14 May 2015 22:35:29 -0400
Message-ID: <20150515023529.GJ23739@momjian.us> (raw)
In-Reply-To: <CAAS3tyKOvC-5dRqQLj+T=tuHmrsVetBznFOwRgvLFYuzjtE90w@mail.gmail.com>
References: <D5359E0908278642BB1747131D62694DAB22560F@AUSMXMBX01.mrws.biz>
	<20141206140708.GA28234@momjian.us>
	<D5359E0908278642BB1747131D62694DB37B1A58@AUSMXMBX01.mrws.biz>
	<CAAS3tyLcMjUDfjrqo3+dy257EjBAXkU_08z+GoxswCN-fzq74w@mail.gmail.com>
	<CAAS3tyKOvC-5dRqQLj+T=tuHmrsVetBznFOwRgvLFYuzjtE90w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

On Wed, Feb  4, 2015 at 09:23:56AM +0100, Alexey Klyukin wrote:
> On Tue, Feb 3, 2015 at 10:41 PM, Alexey Klyukin <alexk@hintbits.com> wrote:
> > The path to reproduce the problem is quite simple:
> >
> > - setup the master and the replica setup, and promote the replica,
> > creating a new timeline (timeline 2 by default)
> > - pg_upgrade the promoted replica. This would create a new cluster
> > with the same timeline, but without the history file.
> > - create the streaming-only replica. The streaming replication will
> > never start, since the timeline file is not there. The error messages
> > are:
> >
> > ERROR:  could not open file "pg_xlog/00000002.history": No such file
> > or directory
> > FATAL:  could not receive timeline history file from the primary
> > server: ERROR:  could not open file "pg_xlog/00000002.history": No
> > such file or directory
> >
> > Note that this problem does not occur for the streaming-only replica
> > of the newly created cluster (with a timeline 1), even when there is
> > no timeline history file in the original datadir.
> 
> 
> In our case I solved the problem by manually creating a 00000002.history file
> on master. It consists of the previous timeline (obviously 1), the location when
> the new timeline has been created (lost) and the text reason, which can be
> arbitrary. As for the location, I don't think it matters much, since
> we don't have
> branched timelines and not going to switch to timeline 1 again, I've
> put the value
> of the 'Prior checkpoint location' from pg_controldata on the replica,
> but I think
> I could just put all 0 with the same effect.
> 
> Nevertheless, the question is should pg_upgrade move the timeline history file
> from the old server to the new one, and, to be more specific, are
> there any cases when
> moving such file is not recommended?

Sorry I am just getting to this --- you are right it is a bug.  I was
unaware that pg_upgrade passed the timeline from the old cluster, but it
does so when setting the WAL starting address with pg_resetxlog -l,
which includes the timeline as the first eight hex digits.

I think there are two options:

1)  force pg_resetxlog -l to pass timeline 1
2)  create a WAL history file to match the old cluster's timeline (!= 1)

I don't think we want to be doing #2, so I have developed the attached
patch for #1, which I should backpatch to 9.4.  Do we store the timeline
in any user tables that might be transfered?  Anywhere else?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Attachments:

timeline.diff (text/x-diff, 948B) download diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c new file mode 100644 index fbccc2e..cc81fa0 *** a/src/bin/pg_upgrade/pg_upgrade.c --- b/src/bin/pg_upgrade/pg_upgrade.c *************** copy_clog_xlog_xid(void) *** 473,480 **** /* now reset the wal archives in the new cluster */ prep_status("Resetting WAL archives"); exec_prog(UTILITY_LOG_FILE, NULL, true, ! "\"%s/pg_resetxlog\" -l %s \"%s\"", new_cluster.bindir, ! old_cluster.controldata.nextxlogfile, new_cluster.pgdata); check_ok(); } --- 473,481 ---- /* now reset the wal archives in the new cluster */ prep_status("Resetting WAL archives"); exec_prog(UTILITY_LOG_FILE, NULL, true, ! /* use timeline 1 to match controldata and no WAL history file */ ! "\"%s/pg_resetxlog\" -l 00000001%s \"%s\"", new_cluster.bindir, ! old_cluster.controldata.nextxlogfile + 8, new_cluster.pgdata); check_ok(); }

view thread (8+ messages)  latest in thread

Message-ID: <20150515023529.GJ23739@momjian.us>
Permalink:  ../20150515023529.GJ23739@momjian.us/
Also on:    postgresql.org/message-id/20150515023529.GJ23739@momjian.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: bruce@momjian.us, alexk@hintbits.com, avandras@gmail.com
  Subject: Re: Missing timeline history file after execution of pg_upgrade
  In-Reply-To: <20150515023529.GJ23739@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox