Thread

  1. SSI patch renumbered existing 2PC resource managers??

    Tom Lane <tgl@sss.pgh.pa.us> — 2011-06-13T18:31:23Z

    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
    
    
  2. Re: SSI patch renumbered existing 2PC resource managers??

    Kevin Grittner <kevin.grittner@wicourts.gov> — 2011-06-13T19:15:52Z

    Tom Lane <tgl@sss.pgh.pa.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
    
    
  3. Re: SSI patch renumbered existing 2PC resource managers??

    Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> — 2011-06-13T19:22:19Z

    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
    
    
  4. Re: SSI patch renumbered existing 2PC resource managers??

    Dan Ports <drkp@csail.mit.edu> — 2011-06-13T19:29:24Z

    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/
    
    
  5. Re: SSI patch renumbered existing 2PC resource managers??

    Tom Lane <tgl@sss.pgh.pa.us> — 2011-06-13T19:33:24Z

    Heikki Linnakangas <heikki.linnakangas@enterprisedb.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
    
    
  6. Re: SSI patch renumbered existing 2PC resource managers??

    Dan Ports <drkp@csail.mit.edu> — 2011-06-13T20:29:05Z

    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/
    
    
  7. Re: SSI patch renumbered existing 2PC resource managers??

    Bruce Momjian <bruce@momjian.us> — 2011-06-14T01:03:26Z

    Tom Lane wrote:
    > Heikki Linnakangas <heikki.linnakangas@enterprisedb.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@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + It's impossible for everything to be true. +
    
    
  8. Re: SSI patch renumbered existing 2PC resource managers??

    Tom Lane <tgl@sss.pgh.pa.us> — 2011-06-14T05:09:24Z

    Bruce Momjian <bruce@momjian.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
    
    
  9. Re: SSI patch renumbered existing 2PC resource managers??

    Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> — 2011-06-14T09:40:32Z

    On 13.06.2011 22:33, Tom Lane wrote:
    > Heikki Linnakangas<heikki.linnakangas@enterprisedb.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
    
    
  10. Re: SSI patch renumbered existing 2PC resource managers??

    Bruce Momjian <bruce@momjian.us> — 2011-06-14T12:58:33Z

    Tom Lane wrote:
    > Bruce Momjian <bruce@momjian.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@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + It's impossible for everything to be true. +
    
    
  11. Re: SSI patch renumbered existing 2PC resource managers??

    Bruce Momjian <bruce@momjian.us> — 2011-06-14T18:43:33Z

    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@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + It's impossible for everything to be true. +