Repository navigation
Commit 1b4abc2
committed
xid_wraparound: Fix XID consumption accounting
When the current transaction had not yet been assigned a top-level
XID, consume_xids(n) consumed n + 1 XIDs because the initial top-level
XID allocation was not included in the count. Include that allocation
so that the function consumes exactly n XIDs.
In particular, consume_xids(1) now consumes and returns only the
top-level XID in this case, rather than consuming two XIDs and
returning the second. consume_xids(0) now raises an error instead of
returning the next unallocated XID.
With 32kB blocks, bulk XID consumption could also consume more XIDs
than requested or return an outdated XID. Restrict this optimization
so that consume_xids(n) always consumes exactly n XIDs and returns
the last XID it assigned.
Backpatch to 17, where the xid_wraparound test module was introduced.
Author: Yushi Ogiwara <btogiwarayuushi@oss.nttdata.com>
Author: João Rito <joaovictor.rito@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/2a62f138c9dcb6fcf5889b076d123aa2@oss.nttdata.com
Backpatch-through: 171 parent 83cefb7 commit 1b4abc2
1 file changed
Lines changed: 36 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 42 | + | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
67 | 88 | | |
68 | 89 | | |
69 | 90 | | |
| |||
89 | 110 | | |
90 | 111 | | |
91 | 112 | | |
92 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
93 | 118 | | |
94 | 119 | | |
95 | 120 | | |
| |||
115 | 140 | | |
116 | 141 | | |
117 | 142 | | |
118 | | - | |
| 143 | + | |
119 | 144 | | |
120 | 145 | | |
121 | 146 | | |
| |||
153 | 178 | | |
154 | 179 | | |
155 | 180 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | 181 | | |
165 | 182 | | |
166 | 183 | | |
| |||
193 | 210 | | |
194 | 211 | | |
195 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
196 | 216 | | |
197 | 217 | | |
198 | 218 | | |
| |||
0 commit comments