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

Commit4b65a28

Browse files
committed
New relcache hash table with RelFileNode as key to be used
from bufmgr - it would be nice to have separate hash in smgrfor node <--> fd mappings, but for the moment it's easy toadd new hash to relcache.Fixed small bug in xlog.c:ReadRecord.
1 parentc82c955 commit4b65a28

File tree

8 files changed

+114
-101
lines changed

8 files changed

+114
-101
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.74 2000/10/21 15:43:22 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.75 2000/10/23 04:10:05 vadim Exp $
1212
*
1313
* NOTES
1414
*Transaction aborts can now occur two ways:
@@ -676,6 +676,7 @@ RecordTransactionCommit()
676676
*/
677677
leak=BufferPoolCheckLeak();
678678

679+
#ifndefXLOG
679680
/*
680681
* If no one shared buffer was changed by this transaction then we
681682
* don't flush shared buffers and don't record commit status.
@@ -686,6 +687,7 @@ RecordTransactionCommit()
686687
if (leak)
687688
ResetBufferPool(true);
688689

690+
#endif
689691
/*
690692
* have the transaction access methods record the status of this
691693
* transaction id in the pg_log relation.
@@ -717,13 +719,14 @@ RecordTransactionCommit()
717719
MyLastRecPtr.xlogid=0;
718720
MyLastRecPtr.xrecoff=0;
719721
}
720-
#endif
722+
#else
721723
/*
722724
* Now write the log info to the disk too.
723725
*/
724726
leak=BufferPoolCheckLeak();
725727
FlushBufferPool();
726728
}
729+
#endif
727730

728731
if (leak)
729732
ResetBufferPool(true);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.19 2000/10/21 15:43:22 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.20 2000/10/23 04:10:05 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -991,6 +991,7 @@ got_record:;
991991
nextRecord= (XLogRecord*) ((char*)subrecord+
992992
MAXALIGN(subrecord->xl_len)+SizeOfXLogSubRecord);
993993
}
994+
record->xl_len=len;
994995
EndRecPtr.xlogid=readId;
995996
EndRecPtr.xrecoff=readSeg*XLogSegSize+readOff*BLCKSZ+
996997
SizeOfXLogPHD+SizeOfXLogSubRecord+
@@ -1412,7 +1413,9 @@ StartupXLOG()
14121413
{
14131414
charbuf[8192];
14141415

1415-
sprintf(buf,"REDO @ %u/%u: ",ReadRecPtr.xlogid,ReadRecPtr.xrecoff);
1416+
sprintf(buf,"REDO @ %u/%u; LSN %u/%u: ",
1417+
ReadRecPtr.xlogid,ReadRecPtr.xrecoff,
1418+
EndRecPtr.xlogid,EndRecPtr.xrecoff);
14161419
xlog_outrec(buf,record);
14171420
strcat(buf," - ");
14181421
RmgrTable[record->xl_rmid].rm_desc(buf,

‎src/backend/storage/buffer/buf_init.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.36 2000/10/18 05:50:15 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.37 2000/10/23 04:10:06 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -68,7 +68,6 @@ bits8 *BufferLocks;/* flag bits showing locks I have set */
6868
BufferTag*BufferTagLastDirtied;/* tag buffer had when last
6969
* dirtied by me */
7070
BufferBlindId*BufferBlindLastDirtied;
71-
LockRelId*BufferRelidLastDirtied;
7271
bool*BufferDirtiedByMe;/* T if buf has been dirtied in cur xact */
7372

7473

@@ -252,7 +251,6 @@ InitBufferPool(IPCKey key)
252251
BufferLocks= (bits8*)calloc(NBuffers,sizeof(bits8));
253252
BufferTagLastDirtied= (BufferTag*)calloc(NBuffers,sizeof(BufferTag));
254253
BufferBlindLastDirtied= (BufferBlindId*)calloc(NBuffers,sizeof(BufferBlindId));
255-
BufferRelidLastDirtied= (LockRelId*)calloc(NBuffers,sizeof(LockRelId));
256254
BufferDirtiedByMe= (bool*)calloc(NBuffers,sizeof(bool));
257255
}
258256

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.90 2000/10/22 20:20:49 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.91 2000/10/23 04:10:06 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -54,6 +54,10 @@
5454
#include"storage/smgr.h"
5555
#include"utils/relcache.h"
5656

57+
#ifdefXLOG
58+
#include"catalog/pg_database.h"
59+
#endif
60+
5761
externSPINLOCKBufMgrLock;
5862
externlongintReadBufferCount;
5963
externlongintReadLocalBufferCount;
@@ -611,7 +615,6 @@ BufferAlloc(Relation reln,
611615
/* record the database name and relation name for this buffer */
612616
strcpy(buf->blind.dbname, (DatabaseName) ?DatabaseName :"Recovery");
613617
strcpy(buf->blind.relname,RelationGetPhysicalRelationName(reln));
614-
buf->relId=reln->rd_lockInfo.lockRelId;
615618

616619
INIT_BUFFERTAG(&(buf->tag),reln,blockNum);
617620
if (!BufTableInsert(buf))
@@ -711,7 +714,6 @@ int
711714
FlushBuffer(Bufferbuffer,boolrelease)
712715
{
713716
BufferDesc*bufHdr;
714-
Oidbufdb;
715717
Relationbufrel;
716718
intstatus;
717719

@@ -725,10 +727,7 @@ FlushBuffer(Buffer buffer, bool release)
725727

726728
bufHdr=&BufferDescriptors[buffer-1];
727729

728-
bufdb=bufHdr->relId.dbId;
729-
730-
Assert(bufdb==MyDatabaseId||bufdb== (Oid)NULL);
731-
bufrel=RelationIdCacheGetRelation(bufHdr->relId.relId);
730+
bufrel=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
732731

733732
Assert(bufrel!= (Relation)NULL);
734733

@@ -904,7 +903,7 @@ SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
904903
SpinRelease(BufMgrLock);
905904
#endif/* OPTIMIZE_SINGLE */
906905

907-
reln=RelationIdCacheGetRelation(BufferRelidLastDirtied[buffer-1].relId);
906+
reln=RelationNodeCacheGetRelation(tagLastDirtied->rnode);
908907

909908
if (reln== (Relation)NULL)
910909
{
@@ -938,7 +937,6 @@ SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
938937
}
939938

940939
*tagLastDirtied=bufHdr->tag;
941-
BufferRelidLastDirtied[buffer-1]=bufHdr->relId;
942940
BufferBlindLastDirtied[buffer-1]=bufHdr->blind;
943941
BufferDirtiedByMe[buffer-1]= true;
944942
}
@@ -1010,15 +1008,14 @@ BufferSync()
10101008
if (RelFileNodeEquals(bufHdr->tag.rnode,BufferTagLastDirtied[i].rnode)&&
10111009
bufHdr->tag.blockNum==BufferTagLastDirtied[i].blockNum)
10121010
{
1013-
Oidbufrel=bufHdr->relId.relId;
1014-
10151011
/*
10161012
* Try to find relation for buf. This could fail, if the
10171013
* rel has been flushed from the relcache since we dirtied
10181014
* the page. That should be uncommon, so paying the extra
10191015
* cost of a blind write when it happens seems OK.
10201016
*/
1021-
reln=RelationIdCacheGetRelation(bufrel);
1017+
if (!InRecovery)
1018+
reln=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
10221019

10231020
/*
10241021
* We have to pin buffer to keep anyone from stealing it
@@ -1083,8 +1080,6 @@ BufferSync()
10831080
}
10841081
else
10851082
{
1086-
Assert(RelFileNodeEquals(reln->rd_node,
1087-
BufferTagLastDirtied[i].rnode));
10881083
status=smgrwrite(DEFAULT_SMGR,reln,
10891084
bufHdr->tag.blockNum,
10901085
(char*)MAKE_PTR(bufHdr->data));
@@ -1138,7 +1133,7 @@ BufferSync()
11381133
SpinRelease(BufMgrLock);
11391134
#endif/* OPTIMIZE_SINGLE */
11401135

1141-
reln=RelationIdCacheGetRelation(BufferRelidLastDirtied[i].relId);
1136+
reln=RelationNodeCacheGetRelation(BufferTagLastDirtied[i].rnode);
11421137
if (reln== (Relation)NULL)
11431138
{
11441139
status=smgrblindmarkdirty(DEFAULT_SMGR,
@@ -1147,8 +1142,6 @@ BufferSync()
11471142
}
11481143
else
11491144
{
1150-
Assert(RelFileNodeEquals(reln->rd_node,
1151-
BufferTagLastDirtied[i].rnode));
11521145
status=smgrmarkdirty(DEFAULT_SMGR,reln,
11531146
BufferTagLastDirtied[i].blockNum);
11541147

@@ -1420,21 +1413,14 @@ static int
14201413
BufferReplace(BufferDesc*bufHdr)
14211414
{
14221415
Relationreln;
1423-
Oidbufdb,
1424-
bufrel;
14251416
intstatus;
14261417

14271418
/*
14281419
* first try to find the reldesc in the cache, if no luck, don't
14291420
* bother to build the reldesc from scratch, just do a blind write.
14301421
*/
1431-
bufdb=bufHdr->relId.dbId;
1432-
bufrel=bufHdr->relId.relId;
14331422

1434-
if (bufdb==MyDatabaseId||bufdb== (Oid)NULL)
1435-
reln=RelationIdCacheGetRelation(bufrel);
1436-
else
1437-
reln= (Relation)NULL;
1423+
reln=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
14381424

14391425
/* To check if block content changed while flushing. - vadim 01/17/97 */
14401426
bufHdr->flags &= ~BM_JUST_DIRTIED;
@@ -1450,7 +1436,6 @@ BufferReplace(BufferDesc *bufHdr)
14501436

14511437
if (reln!= (Relation)NULL)
14521438
{
1453-
Assert(RelFileNodeEquals(bufHdr->tag.rnode,reln->rd_node));
14541439
status=smgrwrite(DEFAULT_SMGR,reln,bufHdr->tag.blockNum,
14551440
(char*)MAKE_PTR(bufHdr->data));
14561441
}
@@ -1519,7 +1504,6 @@ RelationGetNumberOfBlocks(Relation relation)
15191504
void
15201505
ReleaseRelationBuffers(Relationrel)
15211506
{
1522-
Oidrelid=RelationGetRelid(rel);
15231507
inti;
15241508
BufferDesc*bufHdr;
15251509

@@ -1534,10 +1518,6 @@ ReleaseRelationBuffers(Relation rel)
15341518
LocalRefCount[i]=0;
15351519
bufHdr->tag.rnode.relNode=InvalidOid;
15361520
}
1537-
else
1538-
{
1539-
Assert(bufHdr->relId.relId!=relid);
1540-
}
15411521
}
15421522
return;
15431523
}
@@ -1590,12 +1570,6 @@ ReleaseRelationBuffers(Relation rel)
15901570
*/
15911571
BufTableDelete(bufHdr);
15921572
}
1593-
else
1594-
{
1595-
Assert(bufHdr->relId.relId!=relid||
1596-
(bufHdr->relId.dbId!=MyDatabaseId&&
1597-
bufHdr->relId.dbId!=InvalidOid));
1598-
}
15991573

16001574
/*
16011575
* Also check to see if BufferDirtiedByMe info for this buffer
@@ -1608,7 +1582,7 @@ ReleaseRelationBuffers(Relation rel)
16081582
* this rel, since we hold exclusive lock on this rel.
16091583
*/
16101584
if (RelFileNodeEquals(rel->rd_node,
1611-
BufferTagLastDirtied[i-1].rnode))
1585+
BufferTagLastDirtied[i-1].rnode))
16121586
BufferDirtiedByMe[i-1]= false;
16131587
}
16141588

@@ -1673,11 +1647,6 @@ DropBuffers(Oid dbid)
16731647
*/
16741648
BufTableDelete(bufHdr);
16751649
}
1676-
else
1677-
{
1678-
Assert(bufHdr->relId.dbId!=dbid);
1679-
}
1680-
16811650
/*
16821651
* Also check to see if BufferDirtiedByMe info for this buffer
16831652
* refers to the target database, and clear it if so. This is
@@ -1824,7 +1793,6 @@ BufferPoolBlowaway()
18241793
int
18251794
FlushRelationBuffers(Relationrel,BlockNumberfirstDelBlock)
18261795
{
1827-
Oidrelid=RelationGetRelid(rel);
18281796
inti;
18291797
BufferDesc*bufHdr;
18301798

@@ -1857,10 +1825,6 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
18571825
bufHdr->tag.rnode.relNode=InvalidOid;
18581826
}
18591827
}
1860-
else
1861-
{
1862-
Assert(bufHdr->relId.relId!=relid);
1863-
}
18641828
}
18651829
return0;
18661830
}
@@ -1906,12 +1870,6 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
19061870
BufTableDelete(bufHdr);
19071871
}
19081872
}
1909-
else
1910-
{
1911-
Assert(bufHdr->relId.relId!=relid||
1912-
(bufHdr->relId.dbId!=MyDatabaseId&&
1913-
bufHdr->relId.dbId!=InvalidOid));
1914-
}
19151873
}
19161874
SpinRelease(BufMgrLock);
19171875
return0;

‎src/backend/storage/buffer/localbuf.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.31 2000/10/18 05:50:15 vadim Exp $
19+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.32 2000/10/23 04:10:06 vadim Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -103,7 +103,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
103103
*/
104104
if (bufHdr->flags&BM_DIRTY)
105105
{
106-
Relationbufrel=RelationIdCacheGetRelation(bufHdr->relId.relId);
106+
Relationbufrel=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
107107

108108
Assert(bufrel!=NULL);
109109

@@ -127,7 +127,6 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
127127
*/
128128
bufHdr->tag.rnode=reln->rd_node;
129129
bufHdr->tag.blockNum=blockNum;
130-
bufHdr->relId=reln->rd_lockInfo.lockRelId;
131130
bufHdr->flags &= ~BM_DIRTY;
132131

133132
/*
@@ -192,7 +191,7 @@ FlushLocalBuffer(Buffer buffer, bool release)
192191
bufid=-(buffer+1);
193192
bufHdr=&LocalBufferDescriptors[bufid];
194193
bufHdr->flags &= ~BM_DIRTY;
195-
bufrel=RelationIdCacheGetRelation(bufHdr->relId.relId);
194+
bufrel=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
196195

197196
Assert(bufrel!=NULL);
198197
smgrflush(DEFAULT_SMGR,bufrel,bufHdr->tag.blockNum,
@@ -268,7 +267,7 @@ LocalBufferSync(void)
268267
#ifdefLBDEBUG
269268
fprintf(stderr,"LB SYNC %d\n",-i-1);
270269
#endif
271-
bufrel=RelationIdCacheGetRelation(buf->relId.relId);
270+
bufrel=RelationNodeCacheGetRelation(buf->tag.rnode);
272271

273272
Assert(bufrel!=NULL);
274273

@@ -279,7 +278,6 @@ LocalBufferSync(void)
279278
/* drop relcache refcount from RelationIdCacheGetRelation */
280279
RelationDecrementReferenceCount(bufrel);
281280

282-
buf->relId.relId=InvalidOid;
283281
buf->flags &= ~BM_DIRTY;
284282
}
285283
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp