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

Commit53af86c

Browse files
committed
Fix handling of autovacuum reloptions.
In the original coding, setting a single reloption would cause defaultvalues to be used for all the other reloptions. This is a problemparticularly for autovacuum reloptions.Itagaki Takahiro
1 parent8f5500e commit53af86c

File tree

2 files changed

+57
-49
lines changed

2 files changed

+57
-49
lines changed

‎src/backend/access/common/reloptions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.28 2009/06/11 14:48:53 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.29 2009/08/27 17:18:44 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -108,54 +108,54 @@ static relopt_int intRelOpts[] =
108108
"Minimum number of tuple updates or deletes prior to vacuum",
109109
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
110110
},
111-
50,0,INT_MAX
111+
-1,0,INT_MAX
112112
},
113113
{
114114
{
115115
"autovacuum_analyze_threshold",
116116
"Minimum number of tuple inserts, updates or deletes prior to analyze",
117117
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
118118
},
119-
50,0,INT_MAX
119+
-1,0,INT_MAX
120120
},
121121
{
122122
{
123123
"autovacuum_vacuum_cost_delay",
124124
"Vacuum cost delay in milliseconds, for autovacuum",
125125
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
126126
},
127-
20,0,100
127+
-1,0,100
128128
},
129129
{
130130
{
131131
"autovacuum_vacuum_cost_limit",
132132
"Vacuum cost amount available before napping, for autovacuum",
133133
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
134134
},
135-
200,1,10000
135+
-1,1,10000
136136
},
137137
{
138138
{
139139
"autovacuum_freeze_min_age",
140140
"Minimum age at which VACUUM should freeze a table row, for autovacuum",
141141
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
142142
},
143-
100000000,0,1000000000
143+
-1,0,1000000000
144144
},
145145
{
146146
{
147147
"autovacuum_freeze_max_age",
148148
"Age at which to autovacuum a table to prevent transaction ID wraparound",
149149
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
150150
},
151-
200000000,100000000,2000000000
151+
-1,100000000,2000000000
152152
},
153153
{
154154
{
155155
"autovacuum_freeze_table_age",
156156
"Age at which VACUUM should perform a full table sweep to replace old Xid values with FrozenXID",
157157
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
158-
},150000000,0,2000000000
158+
},-1,0,2000000000
159159
},
160160
/* list terminator */
161161
{{NULL}}
@@ -169,15 +169,15 @@ static relopt_real realRelOpts[] =
169169
"Number of tuple updates or deletes prior to vacuum as a fraction of reltuples",
170170
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
171171
},
172-
0.2,0.0,100.0
172+
-1,0.0,100.0
173173
},
174174
{
175175
{
176176
"autovacuum_analyze_scale_factor",
177177
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
178178
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST
179179
},
180-
0.1,0.0,100.0
180+
-1,0.0,100.0
181181
},
182182
/* list terminator */
183183
{{NULL}}

‎src/backend/postmaster/autovacuum.c

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.102 2009/08/24 17:23:02 alvherre Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.103 2009/08/27 17:18:44 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -2448,25 +2448,29 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
24482448
* toast table, try the main table too. Otherwise use the GUC
24492449
* defaults, autovacuum's own first and plain vacuum second.
24502450
*/
2451-
if (avopts)
2452-
{
2453-
vac_cost_delay=avopts->vacuum_cost_delay;
2454-
vac_cost_limit=avopts->vacuum_cost_limit;
2455-
freeze_min_age=avopts->freeze_min_age;
2456-
freeze_table_age=avopts->freeze_table_age;
2457-
}
2458-
else
2459-
{
2460-
/* -1 in autovac setting means use plain vacuum_cost_delay */
2461-
vac_cost_delay=autovacuum_vac_cost_delay >=0 ?
2462-
autovacuum_vac_cost_delay :VacuumCostDelay;
2463-
/* 0 or -1 in autovac setting means use plain vacuum_cost_limit */
2464-
vac_cost_limit=autovacuum_vac_cost_limit>0 ?
2465-
autovacuum_vac_cost_limit :VacuumCostLimit;
2466-
/* these do not have autovacuum-specific settings */
2467-
freeze_min_age=default_freeze_min_age;
2468-
freeze_table_age=default_freeze_table_age;
2469-
}
2451+
2452+
/* -1 in autovac setting means use plain vacuum_cost_delay */
2453+
vac_cost_delay= (avopts&&avopts->vacuum_cost_delay >=0)
2454+
?avopts->vacuum_cost_delay
2455+
: (autovacuum_vac_cost_delay >=0)
2456+
?autovacuum_vac_cost_delay
2457+
:VacuumCostDelay;
2458+
2459+
/* 0 or -1 in autovac setting means use plain vacuum_cost_limit */
2460+
vac_cost_limit= (avopts&&avopts->vacuum_cost_limit>0)
2461+
?avopts->vacuum_cost_limit
2462+
: (autovacuum_vac_cost_limit>0)
2463+
?autovacuum_vac_cost_limit
2464+
:VacuumCostLimit;
2465+
2466+
/* these do not have autovacuum-specific settings */
2467+
freeze_min_age= (avopts&&avopts->freeze_min_age >=0)
2468+
?avopts->freeze_min_age
2469+
:default_freeze_min_age;
2470+
2471+
freeze_table_age= (avopts&&avopts->freeze_table_age >=0)
2472+
?avopts->freeze_table_age
2473+
:default_freeze_table_age;
24702474

24712475
tab=palloc(sizeof(autovac_table));
24722476
tab->at_relid=relid;
@@ -2563,25 +2567,29 @@ relation_needs_vacanalyze(Oid relid,
25632567
* sources: the passed reloptions (which could be a main table or a toast
25642568
* table), or the autovacuum GUC variables.
25652569
*/
2566-
if (relopts)
2567-
{
2568-
vac_scale_factor=relopts->vacuum_scale_factor;
2569-
vac_base_thresh=relopts->vacuum_threshold;
2570-
anl_scale_factor=relopts->analyze_scale_factor;
2571-
anl_base_thresh=relopts->analyze_threshold;
2572-
freeze_max_age=Min(relopts->freeze_max_age,
2573-
autovacuum_freeze_max_age);
2574-
av_enabled=relopts->enabled;
2575-
}
2576-
else
2577-
{
2578-
vac_scale_factor=autovacuum_vac_scale;
2579-
vac_base_thresh=autovacuum_vac_thresh;
2580-
anl_scale_factor=autovacuum_anl_scale;
2581-
anl_base_thresh=autovacuum_anl_thresh;
2582-
freeze_max_age=autovacuum_freeze_max_age;
2583-
av_enabled= true;
2584-
}
2570+
2571+
/* -1 in autovac setting means use plain vacuum_cost_delay */
2572+
vac_scale_factor= (relopts&&relopts->vacuum_scale_factor >=0)
2573+
?relopts->vacuum_scale_factor
2574+
:autovacuum_vac_scale;
2575+
2576+
vac_base_thresh= (relopts&&relopts->vacuum_threshold >=0)
2577+
?relopts->vacuum_threshold
2578+
:autovacuum_vac_thresh;
2579+
2580+
anl_scale_factor= (relopts&&relopts->analyze_scale_factor >=0)
2581+
?relopts->analyze_scale_factor
2582+
:autovacuum_anl_scale;
2583+
2584+
anl_base_thresh= (relopts&&relopts->analyze_threshold >=0)
2585+
?relopts->analyze_threshold
2586+
:autovacuum_anl_thresh;
2587+
2588+
freeze_max_age= (relopts&&relopts->freeze_max_age >=0)
2589+
?Min(relopts->freeze_max_age,autovacuum_freeze_max_age)
2590+
:autovacuum_freeze_max_age;
2591+
2592+
av_enabled= (relopts ?relopts->enabled : true);
25852593

25862594
/* Force vacuum if table is at risk of wraparound */
25872595
xidForceLimit=recentXid-freeze_max_age;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp