osm2pgsql-dev / osm2pgsql

OpenStreetMap data to PostgreSQL converter
https://osm2pgsql.org
GNU General Public License v2.0
1.51k stars 474 forks source link

Out of bounds tile coordinates produced #2142

Closed pnorman closed 8 months ago

pnorman commented 8 months ago

What version of osm2pgsql are you using?

2024-03-04 18:37:49 osm2pgsql version 1.11.0 (1.11.0) Build: RelWithDebInfo Compiled using the following library versions: Libosmium 2.20.0 Proj [API 6] 9.1.1 Lua 5.3.6

What did you do exactly?

When running my update script I got an error with a tile coordinate not between 0 and 2^z-1.

#!/bin/bash
set -e
while :
do
date
SEQUENCE=$(osm2pgsql-replication status -d flex --json | jq '.local.sequence')
LUA_PATH="$HOME/osm2pgsql-themepark/lua/?.lua;;" osm2pgsql-replication update -d flex --once -- --expire-tiles=10-14 -o "expire_files/$SEQUENCE.txt"
cat  "expire_files/$SEQUENCE.txt" | tilekiln/bin/tilekiln generate tiles --source-dbname flex --storage-dbname tiles --config shortbread.yaml -n1
sleep 60
done

Upon inspection, SEQUENCE=5986020 and the last lines of the file are

14/701/16384
13/350/8192
12/175/4096
11/87/2048
10/43/1024

These appear to be the only tiles out of bounds.

The in-DB metadata is

flex=# select * from osm2pgsql_properties ;
          property           |                        value
-----------------------------+-----------------------------------------------------
 attributes                  | false
 db_format                   | 2
 flat_node_file              | /home/pnorman/spirit/nodes.bin
 import_timestamp            | 2024-02-12T01:00:00Z
 output                      | flex
 prefix                      | planet_osm
 style                       | /home/pnorman/spirit/shortbread.lua
 updatable                   | true
 version                     | 1.11.0
 current_timestamp           | 2024-03-02T01:01:57Z
 replication_base_url        | https://planet.openstreetmap.org/replication/minute
 replication_sequence_number | 5986023
 replication_timestamp       | 2024-03-02T01:01:57Z
(13 rows)

This means that the diff that causes the problem is > 5986020 and <= 5986023. I have not yet inspected the diffs.

joto commented 8 months ago

Seems to be a really old off-by-one error. @pnorman Can you check the PR fixes this for you?

pnorman commented 8 months ago

I've put it on my server but had to advance past this diff, so I'll see if it comes up again. It has happened more than once, but less often than once a day.

lonvia commented 8 months ago

Fixed in #2143.