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

Commitf5ea92e

Browse files
committed
Expose oldSnapshotControl definition via new header.
This makes it possible for code outside snapmgr.c to examine thecontents of this data structure. This commit does not add any codewhich actually does so; a subsequent commit will make that change.Patch by me, reviewed by Thomas Munro, Dilip Kumar, Hamid Akhtar.Discussion:http://postgr.es/m/CA+TgmoY=aqf0zjTD+3dUWYkgMiNDegDLFjo+6ze=Wtpik+3XqA@mail.gmail.com
1 parentfc5f107 commitf5ea92e

File tree

2 files changed

+77
-53
lines changed

2 files changed

+77
-53
lines changed

‎src/backend/utils/time/snapmgr.c

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include"storage/spin.h"
6565
#include"utils/builtins.h"
6666
#include"utils/memutils.h"
67+
#include"utils/old_snapshot.h"
6768
#include"utils/rel.h"
6869
#include"utils/resowner_private.h"
6970
#include"utils/snapmgr.h"
@@ -76,59 +77,7 @@
7677
*/
7778
intold_snapshot_threshold;/* number of minutes, -1 disables */
7879

79-
/*
80-
* Structure for dealing with old_snapshot_threshold implementation.
81-
*/
82-
typedefstructOldSnapshotControlData
83-
{
84-
/*
85-
* Variables for old snapshot handling are shared among processes and are
86-
* only allowed to move forward.
87-
*/
88-
slock_tmutex_current;/* protect current_timestamp */
89-
TimestampTzcurrent_timestamp;/* latest snapshot timestamp */
90-
slock_tmutex_latest_xmin;/* protect latest_xmin and next_map_update */
91-
TransactionIdlatest_xmin;/* latest snapshot xmin */
92-
TimestampTznext_map_update;/* latest snapshot valid up to */
93-
slock_tmutex_threshold;/* protect threshold fields */
94-
TimestampTzthreshold_timestamp;/* earlier snapshot is old */
95-
TransactionIdthreshold_xid;/* earlier xid may be gone */
96-
97-
/*
98-
* Keep one xid per minute for old snapshot error handling.
99-
*
100-
* Use a circular buffer with a head offset, a count of entries currently
101-
* used, and a timestamp corresponding to the xid at the head offset. A
102-
* count_used value of zero means that there are no times stored; a
103-
* count_used value of OLD_SNAPSHOT_TIME_MAP_ENTRIES means that the buffer
104-
* is full and the head must be advanced to add new entries. Use
105-
* timestamps aligned to minute boundaries, since that seems less
106-
* surprising than aligning based on the first usage timestamp. The
107-
* latest bucket is effectively stored within latest_xmin. The circular
108-
* buffer is updated when we get a new xmin value that doesn't fall into
109-
* the same interval.
110-
*
111-
* It is OK if the xid for a given time slot is from earlier than
112-
* calculated by adding the number of minutes corresponding to the
113-
* (possibly wrapped) distance from the head offset to the time of the
114-
* head entry, since that just results in the vacuuming of old tuples
115-
* being slightly less aggressive. It would not be OK for it to be off in
116-
* the other direction, since it might result in vacuuming tuples that are
117-
* still expected to be there.
118-
*
119-
* Use of an SLRU was considered but not chosen because it is more
120-
* heavyweight than is needed for this, and would probably not be any less
121-
* code to implement.
122-
*
123-
* Persistence is not needed.
124-
*/
125-
inthead_offset;/* subscript of oldest tracked time */
126-
TimestampTzhead_timestamp;/* time corresponding to head xid */
127-
intcount_used;/* how many slots are in use */
128-
TransactionIdxid_by_minute[FLEXIBLE_ARRAY_MEMBER];
129-
}OldSnapshotControlData;
130-
131-
staticvolatileOldSnapshotControlData*oldSnapshotControl;
80+
volatileOldSnapshotControlData*oldSnapshotControl;
13281

13382

13483
/*

‎src/include/utils/old_snapshot.h

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* old_snapshot.h
4+
*Data structures for 'snapshot too old'
5+
*
6+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
* IDENTIFICATION
10+
* src/include/utils/old_snapshot.h
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
15+
#ifndefOLD_SNAPSHOT_H
16+
#defineOLD_SNAPSHOT_H
17+
18+
#include"datatype/timestamp.h"
19+
#include"storage/s_lock.h"
20+
21+
/*
22+
* Structure for dealing with old_snapshot_threshold implementation.
23+
*/
24+
typedefstructOldSnapshotControlData
25+
{
26+
/*
27+
* Variables for old snapshot handling are shared among processes and are
28+
* only allowed to move forward.
29+
*/
30+
slock_tmutex_current;/* protect current_timestamp */
31+
TimestampTzcurrent_timestamp;/* latest snapshot timestamp */
32+
slock_tmutex_latest_xmin;/* protect latest_xmin and next_map_update */
33+
TransactionIdlatest_xmin;/* latest snapshot xmin */
34+
TimestampTznext_map_update;/* latest snapshot valid up to */
35+
slock_tmutex_threshold;/* protect threshold fields */
36+
TimestampTzthreshold_timestamp;/* earlier snapshot is old */
37+
TransactionIdthreshold_xid;/* earlier xid may be gone */
38+
39+
/*
40+
* Keep one xid per minute for old snapshot error handling.
41+
*
42+
* Use a circular buffer with a head offset, a count of entries currently
43+
* used, and a timestamp corresponding to the xid at the head offset. A
44+
* count_used value of zero means that there are no times stored; a
45+
* count_used value of OLD_SNAPSHOT_TIME_MAP_ENTRIES means that the buffer
46+
* is full and the head must be advanced to add new entries. Use
47+
* timestamps aligned to minute boundaries, since that seems less
48+
* surprising than aligning based on the first usage timestamp. The
49+
* latest bucket is effectively stored within latest_xmin. The circular
50+
* buffer is updated when we get a new xmin value that doesn't fall into
51+
* the same interval.
52+
*
53+
* It is OK if the xid for a given time slot is from earlier than
54+
* calculated by adding the number of minutes corresponding to the
55+
* (possibly wrapped) distance from the head offset to the time of the
56+
* head entry, since that just results in the vacuuming of old tuples
57+
* being slightly less aggressive. It would not be OK for it to be off in
58+
* the other direction, since it might result in vacuuming tuples that are
59+
* still expected to be there.
60+
*
61+
* Use of an SLRU was considered but not chosen because it is more
62+
* heavyweight than is needed for this, and would probably not be any less
63+
* code to implement.
64+
*
65+
* Persistence is not needed.
66+
*/
67+
inthead_offset;/* subscript of oldest tracked time */
68+
TimestampTzhead_timestamp;/* time corresponding to head xid */
69+
intcount_used;/* how many slots are in use */
70+
TransactionIdxid_by_minute[FLEXIBLE_ARRAY_MEMBER];
71+
}OldSnapshotControlData;
72+
73+
externPGDLLIMPORTvolatileOldSnapshotControlData*oldSnapshotControl;
74+
75+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp