pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Bruce Momjian <bruce@momjian.us>
Cc: Andres Freund <andres@2ndquadrant.com>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts
Date: Thu, 19 Jun 2014 18:12:41 -0400
Message-ID: <20140619221240.GC27747@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <20140619220425.GQ18688@eldon.alvh.no-ip.org>
References: <20140619020633.GA20469@momjian.us>
	<20140619015205.GD3806@momjian.us>
	<20140619014034.GC3806@momjian.us>
	<20140619220425.GQ18688@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

BTW I hacked up pg_resetxlog a bit to make it generate the necessary
pg_multixact/offset file when -m is given.  This is not acceptable for
commit because it duplicates the #defines from pg_multixact.c, but maybe
we want this functionality enough that we're interested in a more
complete version of this patch; also it unconditionally writes one zero
byte to the file, which is of course wrong if the file exists and
already contains data.

It'd be nice to be able to write this in a way that lets it work for all
existing SLRU users (pg_clog is the most common, but
pg_multixact/members and the predicate locking stuff might also be
useful).  Not sure what would that look like.

Another consideration is that it doesn't remove existing files that are
outside of the new valid range according to freezing parameters and
such, but I'm not sure this is really doable considering that we might
need to change the relminmxid and datminmxid values, etc.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

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

Attachments:

resetxlog_multi.patch (text/x-diff, 1.9K) download diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 54cc5b0..a094490 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -74,6 +74,7 @@ static void KillExistingXLOG(void); static void KillExistingArchiveStatus(void); static void WriteEmptyXLOG(void); static void usage(void); +static void ensure_multi(MultiXactId multi); int @@ -325,7 +326,10 @@ main(int argc, char *argv[]) ControlFile.checkPointCopy.nextOid = set_oid; if (set_mxid != 0) + { ControlFile.checkPointCopy.nextMulti = set_mxid; + ensure_multi(set_mxid); + } if (set_mxoff != -1) ControlFile.checkPointCopy.nextMultiOffset = set_mxoff; @@ -1013,6 +1017,43 @@ WriteEmptyXLOG(void) close(fd); } +static void +ensure_multi(MultiXactId multi) +{ + char path[MAXPGPATH]; + int fd; + char abyte; + int offset; + +#define SLRU_PAGES_PER_SEGMENT 32 +#define MULTIXACT_OFFSETS_PER_PAGE (BLCKSZ / sizeof(MultiXactOffset)) +#define MultiXactIdToOffsetPage(xid) \ + ((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE) + + snprintf(path, MAXPGPATH, "pg_multixact/offsets/%04X", + MultiXactIdToOffsetPage(multi) / SLRU_PAGES_PER_SEGMENT); + if ((fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) + { + fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"), + progname, path, strerror(errno)); + exit(1); + } + offset = (((multi % (SLRU_PAGES_PER_SEGMENT * MULTIXACT_OFFSETS_PER_PAGE)) / MULTIXACT_OFFSETS_PER_PAGE) + 1) * BLCKSZ - 1; + if (lseek(fd, offset, SEEK_SET) < 0) + { + fprintf(stderr, _("%s: could not seek in file \"%s\" to offset %u: %s\n"), + progname, path, offset, strerror(errno)); + exit(1); + } + abyte = '\0'; + if (write(fd, &abyte, 1) != 1) + { + fprintf(stderr, _("%s: could not write one byte in file \"%s\": %s\n"), + progname, path, strerror(errno)); + exit(1); + } + close(fd); +} static void usage(void)

view thread (78+ messages)  latest in thread

Message-ID: <20140619221240.GC27747@eldon.alvh.no-ip.org>
Permalink:  ../20140619221240.GC27747@eldon.alvh.no-ip.org/
Also on:    postgresql.org/message-id/20140619221240.GC27747@eldon.alvh.no-ip.org

 ·  · 

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-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, bruce@momjian.us, andres@2ndquadrant.com
  Subject: Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts
  In-Reply-To: <20140619221240.GC27747@eldon.alvh.no-ip.org>

* 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