NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I use to get extracts of 4 small areas. I merge those with "osmium" into one .osm.pbf that i import with osm2pgsql. This works great with 3 of those extracts, but after adding the 4th I get the following error when importing the data: DB writer thread failed due to ERROR: result COPY_END for planet_osm_rels failed: ERROR: duplicate key value violates unique constraint "planet_osm_rels_pkey" DETAIL: Key (id)=(21510) already exists. CONTEXT: COPY planet_osm_rels, line 43

Any idea how to fix this?


asked 17 Jun '21, 09:50

Marx1st's gravatar image

accept rate: 0%

Difficult to say without all the details like the file contents, osm2pgsql version used, command line used etc.

Chances are you have different versions of the same object in the input files. This can happen when you downloaded those areas at different points in time.

(18 Jun '21, 07:50) Jochen Topf

Yeah, I don't think it is a bug, but rather a problem with the "workflow" I've chosen. I've now downloaded the boundaries as .geojson and used those with "osmium extract" on a .pbf of Germany (from Geofabrik) and merged those files with "osmium merge". That .pbf can be imported without problems into the database... So, I've found a solution for that problem, but ain't that happy about it. It's too complicated for the client I'm building this for, to add new extracts...

(19 Jun '21, 12:37) Marx1st

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 Jun '21, 09:50

question was seen: 743 times

last updated: 19 Jun '21, 12:37

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum