Re: SSI patch renumbered existing 2PC resource managers??

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 18:31:23
Message-ID: 5362.1307989883@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

So I finally started actually reading the SSI changes, and I am a tad
distressed by this:

diff --git a/src/include/access/twophase_rmgr.h b/src/include/access/twophase_rmgr.h
index a541d0f..1c7d8bb 100644
--- a/src/include/access/twophase_rmgr.h
+++ b/src/include/access/twophase_rmgr.h
@@ -23,8 +23,9 @@ typedef uint8 TwoPhaseRmgrId;
*/
#define TWOPHASE_RM_END_ID 0
#define TWOPHASE_RM_LOCK_ID 1
-#define TWOPHASE_RM_PGSTAT_ID 2
-#define TWOPHASE_RM_MULTIXACT_ID 3
+#define TWOPHASE_RM_PREDICATELOCK_ID 2
+#define TWOPHASE_RM_PGSTAT_ID 3
+#define TWOPHASE_RM_MULTIXACT_ID 4
#define TWOPHASE_RM_MAX_ID TWOPHASE_RM_MULTIXACT_ID

extern const TwoPhaseCallback twophase_recover_callbacks[];

What was the rationale for changing the assignments of existing 2PC IDs?
So far as I can tell, that breaks pg_upgrade (if there are any open
prepared transactions) for no redeeming social benefit. Is there a
reason why TWOPHASE_RM_PREDICATELOCK_ID has to be 2 and not at the end?

regards, tom lane


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <drkp(at)csail(dot)mit(dot)edu>, "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 19:15:52
Message-ID: 4DF61B98020000250003E550@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> What was the rationale for changing the assignments of existing
> 2PC IDs? So far as I can tell, that breaks pg_upgrade (if there
> are any open prepared transactions) for no redeeming social
> benefit. Is there a reason why TWOPHASE_RM_PREDICATELOCK_ID has
> to be 2 and not at the end?

I'm sure that Dan will jump in if this guess is wrong, but since the
predicate lock code is largely derived from the heavyweight locking
code, it probably seemed to have a minor cosmetic benefit to put it
adjacent to that. It didn't occur to me when the SSI 2PC code went
in, but I can see the problem now that you point it out. The new
entry should be moved to the end for compatibility. Would you like
me to submit a patch to fix this, or should I stay out of your way?

-Kevin


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 19:22:19
Message-ID: 4DF6636B.7070703@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13.06.2011 21:31, Tom Lane wrote:
> So I finally started actually reading the SSI changes, and I am a tad
> distressed by this:
>
> diff --git a/src/include/access/twophase_rmgr.h b/src/include/access/twophase_rmgr.h
> index a541d0f..1c7d8bb 100644
> --- a/src/include/access/twophase_rmgr.h
> +++ b/src/include/access/twophase_rmgr.h
> @@ -23,8 +23,9 @@ typedef uint8 TwoPhaseRmgrId;
> */
> #define TWOPHASE_RM_END_ID 0
> #define TWOPHASE_RM_LOCK_ID 1
> -#define TWOPHASE_RM_PGSTAT_ID 2
> -#define TWOPHASE_RM_MULTIXACT_ID 3
> +#define TWOPHASE_RM_PREDICATELOCK_ID 2
> +#define TWOPHASE_RM_PGSTAT_ID 3
> +#define TWOPHASE_RM_MULTIXACT_ID 4
> #define TWOPHASE_RM_MAX_ID TWOPHASE_RM_MULTIXACT_ID
>
> extern const TwoPhaseCallback twophase_recover_callbacks[];
>
> What was the rationale for changing the assignments of existing 2PC IDs?

As far as I can tell it was for purely cosmetic reasons, to have lock
and predicate lock lines together.

> So far as I can tell, that breaks pg_upgrade (if there are any open
> prepared transactions) for no redeeming social benefit.

Surely pg_upgrade can't work anyway if there's any open prepared
transactions in the database. We're not going to guarantee to keep all
the data structures we write in two-phase state files unchanged over
major releases. If pg_upgrade is not checking for prepared transcations
at the moment, such a check should probably should be added.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 19:29:24
Message-ID: 20110613192923.GS26076@csail.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 13, 2011 at 10:22:19PM +0300, Heikki Linnakangas wrote:
> As far as I can tell it was for purely cosmetic reasons, to have lock
> and predicate lock lines together.

Yes, that is the only reason.

Dan

--
Dan R. K. Ports MIT CSAIL http://drkp.net/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 19:33:24
Message-ID: 6539.1307993604@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> On 13.06.2011 21:31, Tom Lane wrote:
>> So far as I can tell, that breaks pg_upgrade (if there are any open
>> prepared transactions) for no redeeming social benefit.

> Surely pg_upgrade can't work anyway if there's any open prepared
> transactions in the database. We're not going to guarantee to keep all
> the data structures we write in two-phase state files unchanged over
> major releases. If pg_upgrade is not checking for prepared transcations
> at the moment, such a check should probably should be added.

No, pg_upgrade should not be unilaterally refusing that. The correct
way to deal with this consideration is to change the TWOPHASE_MAGIC
number when we make a change in on-disk 2PC state. Which wasn't done
in the SSI patch. We can either change that now, or undo the
unnecessary change in existing RM IDs. I vote for the latter.

regards, tom lane


From: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-13 20:29:05
Message-ID: 20110613202905.GU26076@csail.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 13, 2011 at 03:33:24PM -0400, Tom Lane wrote:
> We can either change that now, or undo the
> unnecessary change in existing RM IDs. I vote for the latter.

Sounds good to me. I'd offer a patch, but it'd probably take you longer
to apply than to make the change yourself.

Dan

--
Dan R. K. Ports MIT CSAIL http://drkp.net/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-14 01:03:26
Message-ID: 201106140103.p5E13Qa07668@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> > On 13.06.2011 21:31, Tom Lane wrote:
> >> So far as I can tell, that breaks pg_upgrade (if there are any open
> >> prepared transactions) for no redeeming social benefit.
>
> > Surely pg_upgrade can't work anyway if there's any open prepared
> > transactions in the database. We're not going to guarantee to keep all
> > the data structures we write in two-phase state files unchanged over
> > major releases. If pg_upgrade is not checking for prepared transcations
> > at the moment, such a check should probably should be added.
>
> No, pg_upgrade should not be unilaterally refusing that. The correct
> way to deal with this consideration is to change the TWOPHASE_MAGIC
> number when we make a change in on-disk 2PC state. Which wasn't done
> in the SSI patch. We can either change that now, or undo the
> unnecessary change in existing RM IDs. I vote for the latter.

Uh, isn't there some physical files in pg_twophase/ that stick around to
keep prepared transactions --- if so, pg_upgrade does not copy them from
the old cluster to the new one. I am also hesistant to do so because
there might be data in there that isn't portable. I like the idea of
adding a check, I assume by reading pg_prepared_xact().

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-14 05:09:24
Message-ID: 17021.1308028164@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Tom Lane wrote:
>> No, pg_upgrade should not be unilaterally refusing that.

> Uh, isn't there some physical files in pg_twophase/ that stick around to
> keep prepared transactions --- if so, pg_upgrade does not copy them from
> the old cluster to the new one. I am also hesistant to do so because
> there might be data in there that isn't portable.

This argument seems a tad peculiar, since the *entire* *point* of
pg_upgrade is to push physical files from one installation into another
even though compatibility isn't guaranteed. It is the program's duty to
understand enough to know whether it can transport the cluster's state
safely. Not to arbitrarily discard state because it might possibly not
be transportable.

regards, tom lane


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-14 09:40:32
Message-ID: 4DF72C90.8000608@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13.06.2011 22:33, Tom Lane wrote:
> Heikki Linnakangas<heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
>> On 13.06.2011 21:31, Tom Lane wrote:
>>> So far as I can tell, that breaks pg_upgrade (if there are any open
>>> prepared transactions) for no redeeming social benefit.
>
>> Surely pg_upgrade can't work anyway if there's any open prepared
>> transactions in the database. We're not going to guarantee to keep all
>> the data structures we write in two-phase state files unchanged over
>> major releases. If pg_upgrade is not checking for prepared transcations
>> at the moment, such a check should probably should be added.
>
> No, pg_upgrade should not be unilaterally refusing that. The correct
> way to deal with this consideration is to change the TWOPHASE_MAGIC
> number when we make a change in on-disk 2PC state. Which wasn't done
> in the SSI patch. We can either change that now, or undo the
> unnecessary change in existing RM IDs. I vote for the latter.

Ok, I've renumbered the existing RMs back the way they were.

I nevertheless don't think it's worthwhile to try to migrate 2pc state
files in pg_upgrade. More than likely, it's a mistake on part of the
admin anyway if there is a prepared transaction open at that point.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-14 12:58:33
Message-ID: 201106141258.p5ECwXG28507@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Tom Lane wrote:
> >> No, pg_upgrade should not be unilaterally refusing that.
>
> > Uh, isn't there some physical files in pg_twophase/ that stick around to
> > keep prepared transactions --- if so, pg_upgrade does not copy them from
> > the old cluster to the new one. I am also hesistant to do so because
> > there might be data in there that isn't portable.
>
> This argument seems a tad peculiar, since the *entire* *point* of
> pg_upgrade is to push physical files from one installation into another
> even though compatibility isn't guaranteed. It is the program's duty to
> understand enough to know whether it can transport the cluster's state
> safely. Not to arbitrarily discard state because it might possibly not
> be transportable.

Well, pg_upgrade succeeds because it does as little as necessary to do
the migration, relying on pg_dump to do much of the migration work at
the catalog level. pg_upgrade tries to be involved as little as
possible with the Postgres code so it doesn't have to be changed
regularly between major versions.

The prepared transaction case seems ugly enough that we don't want
pg_upgrade to have to check every major release if anything changed
about the data stored in prepared transactions. This is the same reason
pg_upgrade doesn't transfer WAL files from the old cluster, just pg_clog
files (which rarely changes its format).

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, drkp(at)csail(dot)mit(dot)edu, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SSI patch renumbered existing 2PC resource managers??
Date: 2011-06-14 18:43:33
Message-ID: 201106141843.p5EIhXG18245@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> > This argument seems a tad peculiar, since the *entire* *point* of
> > pg_upgrade is to push physical files from one installation into another
> > even though compatibility isn't guaranteed. It is the program's duty to
> > understand enough to know whether it can transport the cluster's state
> > safely. Not to arbitrarily discard state because it might possibly not
> > be transportable.
>
> Well, pg_upgrade succeeds because it does as little as necessary to do
> the migration, relying on pg_dump to do much of the migration work at
> the catalog level. pg_upgrade tries to be involved as little as
> possible with the Postgres code so it doesn't have to be changed
> regularly between major versions.
>
> The prepared transaction case seems ugly enough that we don't want
> pg_upgrade to have to check every major release if anything changed
> about the data stored in prepared transactions. This is the same reason
> pg_upgrade doesn't transfer WAL files from the old cluster, just pg_clog
> files (which rarely changes its format).

I have applied the attached pg_upgrade patch to head and 9.1 to fail if
prepared transactions are in the old or new cluster.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/pg_upgrade text/x-diff 2.1 KB