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

Commit6ce0ed2

Browse files
committed
Make critical sections (elog->crash) and interrupt holdoff sections
into distinct concepts, per recent discussion on pghackers.
1 parent75815c3 commit6ce0ed2

File tree

9 files changed

+104
-72
lines changed

9 files changed

+104
-72
lines changed

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

Lines changed: 6 additions & 6 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.94 2001/01/18 18:33:45 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.95 2001/01/19 22:08:46 tgl Exp $
1212
*
1313
* NOTES
1414
*Transaction aborts can now occur two ways:
@@ -1016,7 +1016,7 @@ CommitTransaction(void)
10161016
elog(NOTICE,"CommitTransaction and not in in-progress state ");
10171017

10181018
/* Prevent cancel/die interrupt while cleaning up */
1019-
START_CRIT_SECTION();
1019+
HOLD_INTERRUPTS();
10201020

10211021
/* ----------------
10221022
*Tell the trigger manager that this transaction is about to be
@@ -1087,7 +1087,7 @@ CommitTransaction(void)
10871087
*/
10881088
s->state=TRANS_DEFAULT;
10891089

1090-
END_CRIT_SECTION();
1090+
RESUME_INTERRUPTS();
10911091
}
10921092

10931093
/* --------------------------------
@@ -1101,7 +1101,7 @@ AbortTransaction(void)
11011101
TransactionStates=CurrentTransactionState;
11021102

11031103
/* Prevent cancel/die interrupt while cleaning up */
1104-
START_CRIT_SECTION();
1104+
HOLD_INTERRUPTS();
11051105

11061106
/*
11071107
* Let others to know about no transaction in progress - vadim
@@ -1133,7 +1133,7 @@ AbortTransaction(void)
11331133
*/
11341134
if (s->state==TRANS_DISABLED)
11351135
{
1136-
END_CRIT_SECTION();
1136+
RESUME_INTERRUPTS();
11371137
return;
11381138
}
11391139

@@ -1185,7 +1185,7 @@ AbortTransaction(void)
11851185
*State remains TRANS_ABORT until CleanupTransaction().
11861186
* ----------------
11871187
*/
1188-
END_CRIT_SECTION();
1188+
RESUME_INTERRUPTS();
11891189
}
11901190

11911191
/* --------------------------------

‎src/backend/commands/vacuum.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.183 2001/01/14 05:08:15 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.184 2001/01/19 22:08:46 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1425,9 +1425,6 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
14251425
ToPage=BufferGetPage(cur_buffer);
14261426
Cpage=BufferGetPage(Cbuf);
14271427

1428-
/* NO ELOG(ERROR) TILL CHANGES ARE LOGGED */
1429-
START_CRIT_SECTION();
1430-
14311428
Citemid=PageGetItemId(Cpage,
14321429
ItemPointerGetOffsetNumber(&(tuple.t_self)));
14331430
tuple.t_datamcxt=NULL;
@@ -1442,6 +1439,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
14421439

14431440
RelationInvalidateHeapTuple(onerel,&tuple);
14441441

1442+
/* NO ELOG(ERROR) TILL CHANGES ARE LOGGED */
1443+
START_CRIT_SECTION();
1444+
14451445
TransactionIdStore(myXID, (TransactionId*)&(tuple.t_data->t_cmin));
14461446
tuple.t_data->t_infomask &=
14471447
~(HEAP_XMIN_COMMITTED |HEAP_XMIN_INVALID |HEAP_MOVED_IN);
@@ -1626,6 +1626,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
16261626

16271627
RelationInvalidateHeapTuple(onerel,&tuple);
16281628

1629+
/* NO ELOG(ERROR) TILL CHANGES ARE LOGGED */
1630+
START_CRIT_SECTION();
1631+
16291632
/*
16301633
* Mark new tuple as moved_in by vacuum and store vacuum XID
16311634
* in t_cmin !!!
@@ -1635,9 +1638,6 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
16351638
~(HEAP_XMIN_COMMITTED |HEAP_XMIN_INVALID |HEAP_MOVED_OFF);
16361639
newtup.t_data->t_infomask |=HEAP_MOVED_IN;
16371640

1638-
/* NO ELOG(ERROR) TILL CHANGES ARE LOGGED */
1639-
START_CRIT_SECTION();
1640-
16411641
/* add tuple to the page */
16421642
newoff=PageAddItem(ToPage, (Item)newtup.t_data,tuple_len,
16431643
InvalidOffsetNumber,LP_USED);
@@ -2070,7 +2070,6 @@ vacuum_page(Relation onerel, Buffer buffer, VacPage vacpage)
20702070
PageSetSUI(page,ThisStartUpID);
20712071
}
20722072
END_CRIT_SECTION();
2073-
20742073
}
20752074

20762075
/*

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

Lines changed: 18 additions & 18 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.104 2001/01/14 05:08:15 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.105 2001/01/19 22:08:46 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -873,10 +873,10 @@ WaitIO(BufferDesc *buf, SPINLOCK spinlock)
873873
while ((buf->flags&BM_IO_IN_PROGRESS)!=0)
874874
{
875875
SpinRelease(spinlock);
876-
START_CRIT_SECTION();/* don't want to die() holding the lock... */
876+
HOLD_INTERRUPTS();/* don't want to die() holding the lock... */
877877
S_LOCK(&(buf->io_in_progress_lock));
878878
S_UNLOCK(&(buf->io_in_progress_lock));
879-
END_CRIT_SECTION();
879+
RESUME_INTERRUPTS();
880880
SpinAcquire(spinlock);
881881
}
882882
}
@@ -1027,14 +1027,14 @@ BufmgrCommit(void)
10271027
*Returns the block number associated with a buffer.
10281028
*
10291029
* Note:
1030-
*Assumes that the buffer is valid.
1030+
*Assumes that the buffer is valid and pinned, else the
1031+
*value may be obsolete immediately...
10311032
*/
10321033
BlockNumber
10331034
BufferGetBlockNumber(Bufferbuffer)
10341035
{
10351036
Assert(BufferIsValid(buffer));
10361037

1037-
/* XXX should be a critical section */
10381038
if (BufferIsLocal(buffer))
10391039
returnLocalBufferDescriptors[-buffer-1].tag.blockNum;
10401040
else
@@ -1956,7 +1956,7 @@ UnlockBuffers(void)
19561956
Assert(BufferIsValid(i+1));
19571957
buf=&(BufferDescriptors[i]);
19581958

1959-
START_CRIT_SECTION();/* don't want to die() holding the lock... */
1959+
HOLD_INTERRUPTS();/* don't want to die() holding the lock... */
19601960

19611961
S_LOCK(&(buf->cntx_lock));
19621962

@@ -1986,7 +1986,7 @@ UnlockBuffers(void)
19861986

19871987
BufferLocks[i]=0;
19881988

1989-
END_CRIT_SECTION();
1989+
RESUME_INTERRUPTS();
19901990
}
19911991
}
19921992

@@ -2003,7 +2003,7 @@ LockBuffer(Buffer buffer, int mode)
20032003
buf=&(BufferDescriptors[buffer-1]);
20042004
buflock=&(BufferLocks[buffer-1]);
20052005

2006-
START_CRIT_SECTION();/* don't want to die() holding the lock... */
2006+
HOLD_INTERRUPTS();/* don't want to die() holding the lock... */
20072007

20082008
S_LOCK(&(buf->cntx_lock));
20092009

@@ -2028,7 +2028,7 @@ LockBuffer(Buffer buffer, int mode)
20282028
else
20292029
{
20302030
S_UNLOCK(&(buf->cntx_lock));
2031-
END_CRIT_SECTION();
2031+
RESUME_INTERRUPTS();
20322032
elog(ERROR,"UNLockBuffer: buffer %lu is not locked",buffer);
20332033
}
20342034
}
@@ -2040,9 +2040,9 @@ LockBuffer(Buffer buffer, int mode)
20402040
while (buf->ri_lock||buf->w_lock)
20412041
{
20422042
S_UNLOCK(&(buf->cntx_lock));
2043-
END_CRIT_SECTION();
2043+
RESUME_INTERRUPTS();
20442044
S_LOCK_SLEEP(&(buf->cntx_lock),i++);
2045-
START_CRIT_SECTION();
2045+
HOLD_INTERRUPTS();
20462046
S_LOCK(&(buf->cntx_lock));
20472047
}
20482048
(buf->r_locks)++;
@@ -2068,9 +2068,9 @@ LockBuffer(Buffer buffer, int mode)
20682068
buf->ri_lock= true;
20692069
}
20702070
S_UNLOCK(&(buf->cntx_lock));
2071-
END_CRIT_SECTION();
2071+
RESUME_INTERRUPTS();
20722072
S_LOCK_SLEEP(&(buf->cntx_lock),i++);
2073-
START_CRIT_SECTION();
2073+
HOLD_INTERRUPTS();
20742074
S_LOCK(&(buf->cntx_lock));
20752075
}
20762076
buf->w_lock= true;
@@ -2092,12 +2092,12 @@ LockBuffer(Buffer buffer, int mode)
20922092
else
20932093
{
20942094
S_UNLOCK(&(buf->cntx_lock));
2095-
END_CRIT_SECTION();
2095+
RESUME_INTERRUPTS();
20962096
elog(ERROR,"LockBuffer: unknown lock mode %d",mode);
20972097
}
20982098

20992099
S_UNLOCK(&(buf->cntx_lock));
2100-
END_CRIT_SECTION();
2100+
RESUME_INTERRUPTS();
21012101
}
21022102

21032103
/*
@@ -2118,7 +2118,7 @@ static bool IsForInput;
21182118
*BM_IO_IN_PROGRESS mask is not set for the buffer
21192119
*The buffer is Pinned
21202120
*
2121-
* Because BufMgrLock is held, we are already ina CRIT_SECTION here,
2121+
* Because BufMgrLock is held, we are already inan interrupt holdoff here,
21222122
* and do not need another.
21232123
*/
21242124
staticvoid
@@ -2152,7 +2152,7 @@ StartBufferIO(BufferDesc *buf, bool forInput)
21522152
*BufMgrLock is held
21532153
*The buffer is Pinned
21542154
*
2155-
* Because BufMgrLock is held, we are already ina CRIT_SECTION here,
2155+
* Because BufMgrLock is held, we are already inan interrupt holdoff here,
21562156
* and do not need another.
21572157
*/
21582158
staticvoid
@@ -2170,7 +2170,7 @@ TerminateBufferIO(BufferDesc *buf)
21702170
*BufMgrLock is held
21712171
*The buffer is Pinned
21722172
*
2173-
* Because BufMgrLock is held, we are already ina CRIT_SECTION here,
2173+
* Because BufMgrLock is held, we are already inan interrupt holdoff here,
21742174
* and do not need another.
21752175
*/
21762176
staticvoid

‎src/backend/storage/ipc/ipc.c

Lines changed: 3 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/storage/ipc/ipc.c,v 1.60 2001/01/14 05:08:15 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.61 2001/01/19 22:08:46 tgl Exp $
1212
*
1313
* NOTES
1414
*
@@ -136,7 +136,8 @@ proc_exit(int code)
136136
QueryCancelPending= false;
137137
/* And let's just make *sure* we're not interrupted ... */
138138
ImmediateInterruptOK= false;
139-
CritSectionCount=1;
139+
InterruptHoldoffCount=1;
140+
CritSectionCount=0;
140141

141142
if (DebugLvl>1)
142143
elog(DEBUG,"proc_exit(%d)",code);

‎src/backend/storage/ipc/spin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.29 2001/01/14 05:08:15 tgl Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.30 2001/01/19 22:08:47 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -148,19 +148,19 @@ SpinAcquire(SPINLOCK lockid)
148148
PRINT_SLDEBUG("SpinAcquire",lockid,slckP);
149149
/*
150150
* Acquire the lock, then record that we have done so (for recovery
151-
* in case of elog(ERROR)duringthecritical section). Note we assume
151+
* in case of elog(ERROR)while holdingthelock). Note we assume
152152
* here that S_LOCK will not accept cancel/die interrupts once it has
153153
* acquired the lock. However, interrupts should be accepted while
154-
* waiting, ifCritSectionCount is zero.
154+
* waiting, ifInterruptHoldoffCount is zero.
155155
*/
156156
S_LOCK(&(slckP->shlock));
157157
PROC_INCR_SLOCK(lockid);
158158
/*
159-
* Lock out cancel/die interrupts until we exit thecritical section
159+
* Lock out cancel/die interrupts until we exit thecode section
160160
* protected by the spinlock. This ensures that interrupts will not
161161
* interfere with manipulations of data structures in shared memory.
162162
*/
163-
START_CRIT_SECTION();
163+
HOLD_INTERRUPTS();
164164

165165
PRINT_SLDEBUG("SpinAcquire/done",lockid,slckP);
166166
}
@@ -182,9 +182,9 @@ SpinRelease(SPINLOCK lockid)
182182
PROC_DECR_SLOCK(lockid);
183183
S_UNLOCK(&(slckP->shlock));
184184
/*
185-
* Exit thecritical section entered in SpinAcquire().
185+
* Exit theinterrupt holdoff entered in SpinAcquire().
186186
*/
187-
END_CRIT_SECTION();
187+
RESUME_INTERRUPTS();
188188

189189
PRINT_SLDEBUG("SpinRelease/done",lockid,slckP);
190190
}
@@ -329,7 +329,7 @@ SpinAcquire(SPINLOCK lock)
329329
*/
330330
IpcSemaphoreLock(SpinLockIds[0],lock, false);
331331
PROC_INCR_SLOCK(lock);
332-
START_CRIT_SECTION();
332+
HOLD_INTERRUPTS();
333333
}
334334

335335
/*
@@ -351,7 +351,7 @@ SpinRelease(SPINLOCK lock)
351351
Assert(!MyProc||MyProc->sLocks[lockid]>0);
352352
PROC_DECR_SLOCK(lock);
353353
IpcSemaphoreUnlock(SpinLockIds[0],lock);
354-
END_CRIT_SECTION();
354+
RESUME_INTERRUPTS();
355355
}
356356

357357
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp