Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4488b69

Browse files
committed
Fix nbtree's failure to clear BTScans list during xact abort.
Also, move responsibility for calling vc_abort into main xact.c list of things-to-call-at-abort. What in the world was it doing down inside of TransactionIdAbort()?
1 parent fb491a5 commit 4488b69

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 1 addition & 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/nbtree/nbtpage.c,v 1.30 1999/07/17 20:16:42 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.31 1999/08/08 20:12:50 tgl Exp $
1212
*
1313
* NOTES
1414
* Postgres btree pages look like ordinary relation pages. The opaque
@@ -42,7 +42,6 @@ typedef struct BTMetaPageData
4242
#define BTPageGetMeta(p) \
4343
((BTMetaPageData *) &((PageHeader) p)->pd_linp[0])
4444

45-
extern bool BuildingBtree;
4645

4746
/*
4847
* We use high-concurrency locking on btrees. There are two cases in

src/backend/access/nbtree/nbtscan.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.27 1999/07/15 23:03:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.28 1999/08/08 20:12:51 tgl Exp $
1111
*
1212
*
1313
* NOTES
@@ -43,6 +43,28 @@ static BTScanList BTScans = (BTScanList) NULL;
4343

4444
static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
4545

46+
/*
47+
* AtEOXact_nbtree() --- clean up nbtree subsystem at xact abort or commit.
48+
*
49+
* This is here because it needs to touch this module's static var BTScans.
50+
*/
51+
void
52+
AtEOXact_nbtree(void)
53+
{
54+
/* Note: these actions should only be necessary during xact abort;
55+
* but they can't hurt during a commit.
56+
*/
57+
58+
/* Reset the active-scans list to empty.
59+
* We do not need to free the list elements, because they're all
60+
* palloc()'d, so they'll go away at end of transaction anyway.
61+
*/
62+
BTScans = NULL;
63+
64+
/* If we were building a btree, we ain't anymore. */
65+
BuildingBtree = false;
66+
}
67+
4668
/*
4769
* _bt_regscan() -- register a new scan.
4870
*/

src/backend/access/transam/transam.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.30 1999/07/15 23:03:02 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.31 1999/08/08 20:12:52 tgl Exp $
1111
*
1212
* NOTES
1313
* This file contains the high level access-method interface to the
@@ -20,7 +20,6 @@
2020

2121
#include "access/heapam.h"
2222
#include "catalog/catname.h"
23-
#include "commands/vacuum.h"
2423

2524
static int RecoveryCheckingEnabled(void);
2625
static void TransRecover(Relation logRelation);
@@ -83,12 +82,6 @@ int RecoveryCheckingEnableState = 0;
8382
*/
8483
extern int OidGenLockId;
8584

86-
/* ----------------
87-
* globals that must be reset at abort
88-
* ----------------
89-
*/
90-
extern bool BuildingBtree;
91-
9285

9386
/* ----------------
9487
* recovery checking accessors
@@ -568,11 +561,6 @@ TransactionIdCommit(TransactionId transactionId)
568561
void
569562
TransactionIdAbort(TransactionId transactionId)
570563
{
571-
BuildingBtree = false;
572-
573-
if (VacuumRunning)
574-
vc_abort();
575-
576564
if (AMI_OVERRIDE)
577565
return;
578566

src/backend/access/transam/xact.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.46 1999/07/16 04:58:33 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.47 1999/08/08 20:12:52 tgl Exp $
1111
*
1212
* NOTES
1313
* Transaction aborts can now occur two ways:
@@ -144,9 +144,11 @@
144144
*/
145145
#include "postgres.h"
146146

147+
#include "access/nbtree.h"
147148
#include "catalog/heap.h"
148149
#include "commands/async.h"
149150
#include "commands/sequence.h"
151+
#include "commands/vacuum.h"
150152
#include "libpq/be-fsstubs.h"
151153
#include "storage/proc.h"
152154
#include "utils/inval.h"
@@ -952,6 +954,7 @@ CommitTransaction()
952954
}
953955

954956
RelationPurgeLocalRelation(true);
957+
AtEOXact_nbtree();
955958
AtCommit_Cache();
956959
AtCommit_Locks();
957960
AtCommit_Memory();
@@ -1013,9 +1016,12 @@ AbortTransaction()
10131016
AtAbort_Notify();
10141017
CloseSequences();
10151018
AtEOXact_portals();
1019+
if (VacuumRunning)
1020+
vc_abort();
10161021
RecordTransactionAbort();
10171022
RelationPurgeLocalRelation(false);
10181023
DestroyNoNameRels();
1024+
AtEOXact_nbtree();
10191025
AtAbort_Cache();
10201026
AtAbort_Locks();
10211027
AtAbort_Memory();

src/include/access/nbtree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nbtree.h,v 1.30 1999/07/16 17:07:27 momjian Exp $
9+
* $Id: nbtree.h,v 1.31 1999/08/08 20:12:49 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -250,6 +250,7 @@ extern void btdelete(Relation rel, ItemPointer tid);
250250
extern void _bt_regscan(IndexScanDesc scan);
251251
extern void _bt_dropscan(IndexScanDesc scan);
252252
extern void _bt_adjscans(Relation rel, ItemPointer tid);
253+
extern void AtEOXact_nbtree(void);
253254

254255
/*
255256
* prototypes for functions in nbtsearch.c

0 commit comments

Comments
 (0)