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

When i use the latest osmosis to import china-latest.psm.pbf into openstreetmap database, some error eccurs, it says that unable to insert user with id 3642735 into the database, duplicate key value violates unique constraint "users_display_name_idx", Key (display_name)=(Nodes&Roads) already exists. I drop the openstreetmap database and re-create it before run the osmosis command, so the database is empty, but the error still appears. I also try to import other data file such as jordan-latest.osm.pbf, it runs successfully without any error. Only the china-latest.psm.pbf file can not import correctly. It confuses me serveral days and i still could not find out the solution, anyone can help me or give me some useful tips please,thank you.

The command line is osmosis --read-pbf planet/china-lastet.osm.pbf --write-apidb host="localhost" database="openstreetmap" user="osm" password="osm" validateSchemaVersion="no".

And here is the error log:

Thread for task 1-read-pbf failed org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to insert user with id 3642735 into the database. at org.openstreetmap.osmosis.apidb.v0_6.impl.UserManager.insertUser(UserManager.java:143) at org.openstreetmap.osmosis.apidb.v0_6.impl.UserManager.addOrUpdateUser(UserManager.java:191) at org.openstreetmap.osmosis.apidb.v0_6.ApidbWriter.process(ApidbWriter.java:1098) at crosby.binary.osmosis.OsmosisBinaryParser.parseDense(OsmosisBinaryParser.java:138) at org.openstreetmap.osmosis.osmbinary.BinaryParser.parse(BinaryParser.java:124) at org.openstreetmap.osmosis.osmbinary.BinaryParser.handleBlock(BinaryParser.java:68) at org.openstreetmap.osmosis.osmbinary.file.FileBlock.process(FileBlock.java:135) at org.openstreetmap.osmosis.osmbinary.file.BlockInputStream.process(BlockInputStream.java:34) at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:45) at java.lang.Thread.run(Thread.java:745) Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "users_display_name_idx" 详细:Key (display_name)=(Nodes&Roads) already exists. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363) at org.openstreetmap.osmosis.apidb.v0_6.impl.UserManager.insertUser(UserManager.java:140) ... 9 more

九月 28, 2016 10:04:30 上午 org.openstreetmap.osmosis.core.Osmosis main 严重: Execution aborted. org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks failed. at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146) at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92) at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:328) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:408) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:351) at org.codehaus.classworlds.Launcher.main(Launcher.java:31)

asked 27 Sep '16, 15:36

yuyy's gravatar image

yuyy
236222431
accept rate: 20%

edited 28 Sep '16, 03:05

I assume you are using a download from geofabrik.

The error doesn't ring a bell. Can you give us the complete command line you are using an the complete error log (right now I would suspect a character encoding or similar error).

(27 Sep '16, 23:54) SimonPoole ♦
1

Please never add what should be a comment as an answer and then edit it. That makes it impossible to rearrange questions and comments as they should be.

Back to the question: this looks like an issue somewhere in the API code or the data dumper or on the extract side as this "should not happen".

We've checked and it seems to be a specific issue with the extract you are using. See answer below.

(28 Sep '16, 09:48) SimonPoole ♦

Thanks to your reply, i will be more careful next time.

(28 Sep '16, 09:58) yuyy

The extracts from Geofabrik are kept up to date by applying diffs, as a consequence when a contributor changes their display name this is not propagated to all the data contributed in the extract.

Or put differently: you cannot use Geofabrik extracts to populate an API database with osmosis except if you are very lucky, which you are not.

I would suggest checking with mapzen https://mapzen.com/data/metro-extracts/ or another provider of extracts if they generate them differently.

permanent link

answered 28 Sep '16, 10:06

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

edited 28 Sep '16, 10:08

I transformed the china-latest.osm.pbf into .osc file, and i find that there are two different user_id use the same display_name, one is :

<node id="221454099" version="4" timestamp="2016-02-19T01:31:31Z" uid="1708958" user="Nodes&amp;Roads" changeset="37300193" lat="28.5580746" lon="98.4585189"/>

Another is :

<node id="224205729" version="3" timestamp="2016-02-20T00:02:20Z" uid="3642735" user="Nodes&amp;Roads" changeset="37320893" lat="28.0394804" lon="99.5276968"/>

Maybe we can change one of the display_name in the .osc file to solve the problem. But if i want use the .pbf file, what should i do? I don't know how to edit the .pbf file, i also asked another question here. If someone have some ideal, please answer here.

permanent link

answered 28 Sep '16, 08:58

yuyy's gravatar image

yuyy
236222431
accept rate: 20%

edited 28 Sep '16, 08:59

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×252
×11

question asked: 27 Sep '16, 15:36

question was seen: 3,930 times

last updated: 28 Sep '16, 10:12

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