osm2pgsql problem

Ich frage mal hier, weil da doch einige mit Fachwissen präsent sind. Habe gestern versucht, einen Planet-Extrakt in eine Postgres/Postgis zu importieren, und gegen Ende gab es einen Fehler. Hier die Ausgabe:


% osm2pgsql --slim --username abc -k --database osm 20201103_italy.osm.pbf 
osm2pgsql version 1.3.0

Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=11
Mid: pgsql, cache=800
Setting up table: planet_osm_nodes
Setting up table: planet_osm_ways
Setting up table: planet_osm_rels
Using built-in tag processing pipeline
Using projection SRS 3857 (Spherical Mercator)
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads

Reading in file: 20201103_italy.osm.pbf
Using PBF parser.
Processing: Node(198737k 143.4k/s) Way(21651k 5.23k/s) Relation(347397 410.6/s)  parse time: 6373s
Node stats: total(198737307), max(8079203523) in 1386s
Way stats: total(21651717), max(866788581) in 4141s
Relation stats: total(347397), max(11832253) in 846s
Sorting data and creating indexes for planet_osm_point
Sorting data and creating indexes for planet_osm_line
Sorting data and creating indexes for planet_osm_roads
Sorting data and creating indexes for planet_osm_polygon
Using native order for clustering
Using native order for clustering
Using native order for clustering
Using native order for clustering
Copying planet_osm_roads to cluster by geometry finished
Creating geometry index on planet_osm_roads
Creating osm_id index on planet_osm_roads
Creating indexes on planet_osm_roads finished
All indexes on planet_osm_roads created in 194s
Completed planet_osm_roads
Stopping table: planet_osm_nodes
Stopped table: planet_osm_nodes in 1s
Stopping table: planet_osm_ways
Building index on table: planet_osm_ways
Copying planet_osm_point to cluster by geometry finished
Creating geometry index on planet_osm_point
Creating osm_id index on planet_osm_point
Creating indexes on planet_osm_point finished
All indexes on planet_osm_point created in 878s
Completed planet_osm_point
Stopping table: planet_osm_rels
Building index on table: planet_osm_rels
Stopped table: planet_osm_rels in 68s
Copying planet_osm_line to cluster by geometry finished
Creating geometry index on planet_osm_line
Creating osm_id index on planet_osm_line
Creating indexes on planet_osm_line finished
All indexes on planet_osm_line created in 1873s
Completed planet_osm_line
SQL command failed: ERROR:  could not seek to block 4742566397934611732 of temporary file

Full query: CREATE TABLE planet_osm_polygon_tmp  AS SELECT * FROM planet_osm_polygon WHERE ST_IsValid(way) ORDER BY way
Stopped table: planet_osm_ways in 5448s
node cache: stored: 58377947(29.37%), storage efficiency: 55.67% (dense blocks: 1820, sparse nodes: 44974081), hit rate: 32.50%
Osm2pgsql failed due to ERROR: Executing SQL

Das Problem scheint hier zu liegen: “SQL command failed: ERROR: could not seek to block 4742566397934611732 of temporary file”. Ist das ein Festplattenfehler? Die Blocknummer ist ja viel zu hoch. Oder könnte das auch von osm2pgsql kommen?

In Hex (41d0fb030098ad14) macht die Zahl auch keinen Sinn, außer dass da recht viele “0” drin sind.
Arbeitsspeicher korrupt?

Versuch erstmal rauszufinden, ob der Fehler von postgresql kommt (evt. separates Logfile) oder aus osm2pgsql.

Schuss ins Blaue: Du hast dir postgresql und osm2pgsql als Binaries gezogen, aber die passen nicht ganz auf deine CPU-Architektur bzw. dein OS.

Auf was für einem System (Architektur), OS, usw. machst du das? Wie hast du die Software installiert?

ja, habe mir beides über homebrew geholt, und die Architektur ist Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64

Die Daten scheinen alle* da zu sein, allerdings hat die planet_osm_polygon keine Indexe. Irgendwo müsste doch eigentlich auch noch eine flat.nodes Datei (oder so ähnlich) rumfliegen, oder? Habe ich bisher nicht finden können.

osm=# \d+
                                 List of relations
 Schema |        Name        | Type  | Owner  | Persistence |  Size   | Description 
--------+--------------------+-------+--------+-------------+---------+-------------
 public | geography_columns  | view  | martin | permanent   | 0 bytes | 
 public | geometry_columns   | view  | martin | permanent   | 0 bytes | 
 public | planet_osm_line    | table | martin | permanent   | 2466 MB | 
 public | planet_osm_nodes   | table | martin | permanent   | 8395 MB | 
 public | planet_osm_point   | table | martin | permanent   | 943 MB  | 
 public | planet_osm_polygon | table | martin | unlogged    | 4429 MB | 
 public | planet_osm_rels    | table | martin | permanent   | 145 MB  | 
 public | planet_osm_roads   | table | martin | permanent   | 352 MB  | 
 public | planet_osm_ways    | table | martin | permanent   | 4423 MB | 
 public | spatial_ref_sys    | table | martin | permanent   | 6976 kB | 
(10 rows)

  • ganz sicher bin ich mir natürlich nicht, aber ich habe mal nachgesehen, und die höchste id in der Polygons-tabelle zeigt auf ein Objekt von gestern: https://www.openstreetmap.org/way/866788581 das ist schonmal beruhigend.

Ich habe die Indexe jetzt von Hand so erstellt (hoffe, dass das passt):

CREATE INDEX planet_osm_polygon_osm_id_idx ON planet_osm_polygon USING btree (osm_id);
CREATE INDEX planet_osm_polygon_way_idx ON planet_osm_polygon USING gist (way);

Definitiv kein Fehler von osm2pgsql. Sieht mir jetzt eher nach einem PostgreSQL-Bug aus. Oder vielleich wirklich ein Problem mit der von Dir installierten Version wie Wuld4096 sagt. Kann auch sein, dass Du einfach nicht genug Speicher oder Disk Space hast.

Eine Flat-Nodes-Datei gibt es nur, wenn Du auch die entsprechende Option --flat-nodes angibst. Da Du nur auf einem Italien-Extrakt arbeitest, ist das wahrscheinlich aber nicht sinnvoll.