Commit af89bc8
committed
Introduce per geometry and overall limits on number of expire tiles
The number of tiles to be expired can be quite large if the input
geometries are large or if there are many geometries. Numbers of tiles in
the billions can crash osm2pgsql because it runs out of memory. Such
large numbers can also overwhelm any kind of re-rendering mechanism run
after osm2pgsql to bring tiles up to date. In day-to-day processing this
should not happen, but it can happen due to vandalism or misconfiguration.
To protect against this problem, this change introduces limits on the
number of tiles that can be affected by a single geometry and the
overall number of tiles that an expire output will generate for each run
of osm2pgsql.
* If a single geometry would result in the expire of more than
`max_tiles_geometry` this geometry will be ignored for the purposes of
expiry. Note that the geometry will still be written to the database,
but no tiles will be added to the expire output.
* If the number of tiles generated during a single run of osm2pgsql for an
expire output grows beyond `max_tiles_overall`, no further tiles will be
written to this output.
Limits are per expire output of which you can have several. The limits
can be set in the flex expire output configuration but sensible defaults
are provided. For the (legacy) expire output configured on the command
line with the `-e` and `-o` options, the settings can not be changed,
you will always get the default values.
To choose the default values for these settings I looked at real-world
values as follows:
* Russia has one of the largest boundaries in the planet. Expiry
(boundary only) on zoom level 14 affects 94144 tiles, on z15 190168
tiles, on z16 383465 tiles. For typical raster tiles using 8x8 meta
tiles expiry on z16 is equivalent to showing z19 tiles. So 500,000 tiles
seems to be a useful limit for `max_tiles_geometry`.
* For expiring the area I looked at the Greenland icesheet, which needs
more than 8 million tiles on z14. At least for vector tiles this is
good enough, for raster tiles we might need more though.
* For `max_tiles_overall`: Paul Norman analyzed the number of tiles
expired by typical minutely updates in
https://www.openstreetmap.org/user/pnorman/diary/403266. For zoom level
14 the most he got was 119801 tiles. The same analysis also shows that
for longer time frames (checked were 2 minutes and 5 minutes, but the
same should be true for larger intervals) the number of tiles doesn't go
up because these huge numbers only happen very rarely.
Rounding these numbers and adding a safety factor, values of 10,000,000
and 50,000,000 seem reasonable for the single geometry and the overall
number of tiles per run. Memory use in osm2pgsql is about 32 bytes per
tile, so this will need 1.6 GB max which should be no problem at all.
The numbers are chosen so they will practically never be triggered so
that users upgrading from existing versions of osm2pgsql will not be
suddenly affected. It is recommended that users tune their settings
according to their own needs. Once we have some more operational
experience with this, we can adjust the defaults.
I considered using different default max values for different zoom
levels, but this will make configuration more complicated.
Change file processing in osm2pgsql runs in parallel threads. The old
code stored the to-be-expired tiles in one list per thread and merged
them later. This has two problems:
a) because the lists might contain some of the same tiles, all lists
together can use a much larger amount than a single list would take
b) we can not easily check the number of tiles in those lists against
the configured maximum.
So this commit changes the way the list is kept: We only keep a single
list in the expire_output_t and use a mutex to control access to this
list. (There might still be overlapping lists if you have more than
one expire output, but that's by design.)
Objects of expire_tiles_t class now only keep a temporary list for
each geometry added. Once all tiles affected by a single geometry are
identified, this list is added to the overall list in expire_output_t
and the temporary list is cleared.
Fixes #21901 parent f297910 commit af89bc8
File tree
23 files changed
+442
-238
lines changed- src
- tests
- bdd/flex
- data
23 files changed
+442
-238
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
20 | 71 | | |
21 | | - | |
22 | | - | |
| 72 | + | |
23 | 73 | | |
24 | 74 | | |
25 | 75 | | |
26 | | - | |
| 76 | + | |
27 | 77 | | |
28 | 78 | | |
29 | | - | |
| 79 | + | |
30 | 80 | | |
31 | 81 | | |
32 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
56 | | - | |
57 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
58 | 99 | | |
| 100 | + | |
59 | 101 | | |
60 | 102 | | |
61 | 103 | | |
| |||
75 | 117 | | |
76 | 118 | | |
77 | 119 | | |
78 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
79 | 124 | | |
80 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
81 | 129 | | |
82 | | - | |
83 | 130 | | |
84 | 131 | | |
85 | 132 | | |
| |||
95 | 142 | | |
96 | 143 | | |
97 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
98 | 161 | | |
99 | 162 | | |
100 | 163 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
38 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
43 | 51 | | |
| 52 | + | |
| 53 | + | |
44 | 54 | | |
45 | 55 | | |
46 | 56 | | |
| |||
281 | 291 | | |
282 | 292 | | |
283 | 293 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | 294 | | |
303 | 295 | | |
304 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
88 | 91 | | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
65 | 85 | | |
66 | 86 | | |
67 | 87 | | |
| |||
71 | 91 | | |
72 | 92 | | |
73 | 93 | | |
| 94 | + | |
| 95 | + | |
74 | 96 | | |
75 | 97 | | |
76 | 98 | | |
| |||
106 | 128 | | |
107 | 129 | | |
108 | 130 | | |
109 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
110 | 136 | | |
111 | 137 | | |
112 | 138 | | |
| |||
150 | 176 | | |
151 | 177 | | |
152 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
| 210 | + | |
| 211 | + | |
209 | 212 | | |
210 | 213 | | |
211 | | - | |
212 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
0 commit comments