Skip to content

Commit 284a3e6

Browse files
committed
Bugfix: Nodes not stored in node location store correctly
When importing a planet file or a huge extract, something with more than about 1 billion nodes, the new RAM node location could overflow a 32bit "offset" value which meant that the node locations would not be found again. The result were missing features, because osm2pgsql just ignores features with geometries that can not be built due to missing node locations. This fix has two parts: First, it fixes the typo which made the max block size too large. This typo lead to a doubling of the max block size which directly lead to the bug. The other fix is to check the "offset" value and, if it becomes too large, start a new block. This probably isn't necessary for "normal" OSM data which should usually work with the new max block size, but it provides a safety net in case some the block size becomes too large for some data. See #1540
1 parent 75d41a0 commit 284a3e6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ordered-index.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void ordered_index_t::add(osmid_t id, std::size_t offset)
1919
(last().offset_from + last().index.back().offset) < offset));
2020

2121
if (need_new_2nd_level() ||
22-
(id - last().from) > std::numeric_limits<uint32_t>::max()) {
22+
(id - last().from) > std::numeric_limits<uint32_t>::max() ||
23+
(offset - last().offset_from) >= std::numeric_limits<uint32_t>::max()) {
2324
if (!m_ranges.empty()) {
2425
m_ranges.back().to = id - 1;
2526
}

src/ordered-index.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* An index that is never used doesn't need more memory than
3232
* sizeof(ordered_index_t).
3333
*
34-
* All allocated memory can be freed by calling clear(). Afer that the index
34+
* All allocated memory can be freed by calling clear(). After that the index
3535
* can NOT be reused.
3636
*
3737
* There are two ways of accessing the data through the index:
@@ -185,7 +185,7 @@ class ordered_index_t
185185

186186
std::pair<osmid_t, std::size_t> get_internal(osmid_t id) const noexcept;
187187

188-
static constexpr std::size_t const max_block_size = 16 * 1024 * 1204;
188+
static constexpr std::size_t const max_block_size = 16 * 1024 * 1024;
189189

190190
std::vector<range_entry> m_ranges;
191191
std::size_t m_block_size;

0 commit comments

Comments
 (0)