Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd428c7

Browse files
Fix relcache init file invalidation during Hot Standby for the case
where a database has a non-default tablespaceid. Pass thru MyDatabaseIdand MyDatabaseTableSpace to allow file path to be re-created instandby and correct invalidation to take place in all cases.Update and rework xact_commit_desc() debug messages.Bug report from Tom by code inspection. Fix by me.
1 parenta5acb7d commitdd428c7

File tree

4 files changed

+30
-85
lines changed

4 files changed

+30
-85
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.284 2010/02/08 04:33:53 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.285 2010/02/13 16:15:46 sriggs Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -951,6 +951,9 @@ RecordTransactionCommit(void)
951951
if (forceSyncCommit)
952952
xlrec.xinfo |=XACT_COMPLETION_FORCE_SYNC_COMMIT;
953953

954+
xlrec.dbId=MyDatabaseId;
955+
xlrec.tsId=MyDatabaseTableSpace;
956+
954957
/*
955958
* Mark ourselves as within our "commit critical section".This
956959
* forces any concurrent checkpoint to wait until we've updated
@@ -4412,7 +4415,8 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
44124415
* as occurs in .
44134416
*/
44144417
ProcessCommittedInvalidationMessages(inval_msgs,xlrec->nmsgs,
4415-
XactCompletionRelcacheInitFileInval(xlrec));
4418+
XactCompletionRelcacheInitFileInval(xlrec),
4419+
xlrec->dbId,xlrec->tsId);
44164420

44174421
/*
44184422
* Release locks, if any. We do this for both two phase and normal
@@ -4596,15 +4600,11 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
45964600
{
45974601
inti;
45984602
TransactionId*xacts;
4599-
SharedInvalidationMessage*msgs;
46004603

46014604
xacts= (TransactionId*)&xlrec->xnodes[xlrec->nrels];
4602-
msgs= (SharedInvalidationMessage*)&xacts[xlrec->nsubxacts];
4603-
4604-
if (XactCompletionRelcacheInitFileInval(xlrec))
4605-
appendStringInfo(buf,"; relcache init file inval");
46064605

46074606
appendStringInfoString(buf,timestamptz_to_str(xlrec->xact_time));
4607+
46084608
if (xlrec->nrels>0)
46094609
{
46104610
appendStringInfo(buf,"; rels:");
@@ -4624,6 +4624,14 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
46244624
}
46254625
if (xlrec->nmsgs>0)
46264626
{
4627+
SharedInvalidationMessage*msgs;
4628+
4629+
msgs= (SharedInvalidationMessage*)&xacts[xlrec->nsubxacts];
4630+
4631+
if (XactCompletionRelcacheInitFileInval(xlrec))
4632+
appendStringInfo(buf,"; relcache init file inval dbid %u tsid %u",
4633+
xlrec->dbId,xlrec->tsId);
4634+
46274635
appendStringInfo(buf,"; inval msgs:");
46284636
for (i=0;i<xlrec->nmsgs;i++)
46294637
{

‎src/backend/utils/cache/inval.c

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* Portions Copyright (c) 1994, Regents of the University of California
8181
*
8282
* IDENTIFICATION
83-
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.95 2010/02/08 04:33:54 tgl Exp $
83+
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.96 2010/02/13 16:15:47 sriggs Exp $
8484
*
8585
*-------------------------------------------------------------------------
8686
*/
@@ -861,15 +861,6 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
861861
* ProcessCommittedInvalidationMessages is executed by xact_redo_commit()
862862
* to process invalidation messages added to commit records.
863863
*
864-
* If we have to invalidate the relcache init file we need to extract
865-
* the database id from each message so we can correctly locate the database
866-
* path and so remove that database's init file. We note that the relcache
867-
* only contains entries for catalog tables from a single database, or
868-
* shared relations. There are smgr invalidations that reference other
869-
* databases but they never cause relcache file invalidations.
870-
* So we only need to access either global or default tablespaces and
871-
* never have need to scan pg_database to discover tablespace oids.
872-
*
873864
* Relcache init file invalidation requires processing both
874865
* before and after we send the SI messages. See AtEOXact_Inval()
875866
*
@@ -879,79 +870,22 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
879870
*/
880871
void
881872
ProcessCommittedInvalidationMessages(SharedInvalidationMessage*msgs,
882-
intnmsgs,boolRelcacheInitFileInval)
873+
intnmsgs,boolRelcacheInitFileInval,
874+
Oiddbid,Oidtsid)
883875
{
884-
Oiddboid=0;
885-
boolinvalidate_global= false;
876+
if (nmsgs <=0)
877+
return;
886878

887-
if (nmsgs>0)
888-
elog(trace_recovery(DEBUG4),"replaying commit with %d messages%s",nmsgs,
879+
elog(trace_recovery(DEBUG4),"replaying commit with %d messages%s",nmsgs,
889880
(RelcacheInitFileInval ?" and relcache file invalidation" :""));
890-
else
891-
return;
892881

893882
if (RelcacheInitFileInval)
894-
{
895-
inti;
896-
897-
/*
898-
* Check messages to record dboid
899-
*/
900-
for (i=0;i<nmsgs;i++)
901-
{
902-
SharedInvalidationMessage*inval_msg=&(msgs[i]);
903-
Oidloop_dboid=0;
904-
905-
/*
906-
* Extract the database Oid from the message
907-
*/
908-
if (inval_msg->id >=0)
909-
loop_dboid=inval_msg->cc.dbId;
910-
elseif (inval_msg->id==SHAREDINVALRELCACHE_ID)
911-
loop_dboid=inval_msg->rc.dbId;
912-
else
913-
{
914-
/*
915-
* Invalidation message is a catalog or nontransactional inval,
916-
* which never cause relcache file invalidation,
917-
* so we ignore them, no matter which db they're for.
918-
*/
919-
continue;
920-
}
921-
922-
if (loop_dboid==0)
923-
invalidate_global= true;
924-
else
925-
{
926-
Assert(dboid==0||dboid==loop_dboid);
927-
dboid=loop_dboid;
928-
}
929-
}
930-
931-
/*
932-
* If shared, dboid will be the global tablespace, otherwise it will
933-
* be a local catalog relation in the default tablespace.
934-
*/
935-
if (invalidate_global)
936-
RecoveryRelationCacheInitFileInvalidate(0,GLOBALTABLESPACE_OID, true);
937-
938-
if (dboid!=0)
939-
RecoveryRelationCacheInitFileInvalidate(dboid,DEFAULTTABLESPACE_OID, true);
940-
}
883+
RecoveryRelationCacheInitFileInvalidate(dbid,tsid, true);
941884

942885
SendSharedInvalidMessages(msgs,nmsgs);
943886

944887
if (RelcacheInitFileInval)
945-
{
946-
/*
947-
* Second invalidation, very similar to above. See RelationCacheInitFileInvalidate()
948-
*/
949-
if (invalidate_global)
950-
RecoveryRelationCacheInitFileInvalidate(0,GLOBALTABLESPACE_OID, false);
951-
952-
if (dboid!=0)
953-
RecoveryRelationCacheInitFileInvalidate(dboid,DEFAULTTABLESPACE_OID, false);
954-
}
888+
RecoveryRelationCacheInitFileInvalidate(dbid,tsid, false);
955889
}
956890

957891
/*

‎src/include/access/xact.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/xact.h,v 1.101 2010/02/08 04:33:54 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/access/xact.h,v 1.102 2010/02/13 16:15:47 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -102,6 +102,8 @@ typedef struct xl_xact_commit
102102
intnrels;/* number of RelFileNodes */
103103
intnsubxacts;/* number of subtransaction XIDs */
104104
intnmsgs;/* number of shared inval msgs */
105+
OiddbId;/* MyDatabaseId */
106+
OidtsId;/* MyDatabaseTableSpace */
105107
/* Array of RelFileNode(s) to drop at commit */
106108
RelFileNodexnodes[1];/* VARIABLE LENGTH ARRAY */
107109
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
@@ -119,7 +121,7 @@ typedef struct xl_xact_commit
119121
* transaction completion.
120122
*/
121123
#defineXACT_COMPLETION_UPDATE_RELCACHE_FILE0x01
122-
#defineXACT_COMPLETION_FORCE_SYNC_COMMIT0x04
124+
#defineXACT_COMPLETION_FORCE_SYNC_COMMIT0x02
123125

124126
/* Access macros for above flags */
125127
#defineXactCompletionRelcacheInitFileInval(xlrec)((xlrec)->xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE)

‎src/include/storage/sinval.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.57 2010/02/07 20:48:13 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.58 2010/02/13 16:15:48 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -134,6 +134,7 @@ extern bool DisableCatchupInterrupt(void);
134134
externintxactGetCommittedInvalidationMessages(SharedInvalidationMessage**msgs,
135135
bool*RelcacheInitFileInval);
136136
externvoidProcessCommittedInvalidationMessages(SharedInvalidationMessage*msgs,
137-
intnmsgs,boolRelcacheInitFileInval);
137+
intnmsgs,boolRelcacheInitFileInval,
138+
Oiddbid,Oidtsid);
138139

139140
#endif/* SINVAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp