[OSM-dev] Osmosis error "duplicate entry for key 1"

Brett Henderson brett at bretth.com
Sun Mar 1 05:28:58 GMT 2009


Maarten Deen wrote:
> I have this (for me) unexplainable error "duplicate entry ... for key 1" when 
> trying to load some data into a database with Osmosis (latest, 0.30).
>
> The data is:
> <?xml version='1.0' standalone='no'?>
> <osm version='0.5' generator='osmxapi: OSM Extended API' 
> xmlns:osmxapi='http://www.informationfreeway.org/osmxapi/0.5' 
> osmxapi:uri='/api/0.5/node[amenity=atm][bbox=3.4,50.7,7.2,53.6]' 
> osmxapi:planetDate='200902281146' osmxapi:copyright='2008 OpenStreetMap 
> contributors' osmxapi:instance='zappyHyper'>
>    <node id='27432409' lat='51.4461182' lon='7.0541461' user='SlowRider' 
> osmxapi:users='SlowRider' timestamp='2007-04-17T20:19:14Z'>
>      <tag k='amenity' v='atm'/>
>    </node>
> </osm>
>
> and
>
> <?xml version='1.0' standalone='no'?>
> <osm version='0.5' generator='osmxapi: OSM Extended API' 
> xmlns:osmxapi='http://www.informationfreeway.org/osmxapi/0.5' 
> osmxapi:uri='/api/0.5/node[amenity=bank][bbox=3.4,50.7,7.2,53.6]' 
> osmxapi:planetDate='200902281144' osmxapi:copyright='2008 OpenStreetMap 
> contributors' osmxapi:instance='zappyHyper'>
>    <node id='27432408' lat='51.4459649' lon='7.0533624' user='DocGo' 
> osmxapi:users='DocGo' timestamp='2007-10-16T16:09:19Z'>
>      <tag k='amenity' v='bank'/>
>      <tag k='name' v='Sparkasse'/>
>    </node>
> </osm>
>
>
> If I put these in different files, then the second always fails to load with 
> error "Duplicate entry '27432409' for key 1" when the first file is loaded first 
> or "Duplicate entry '27432408' for key 1" when the second is loaded first.
> If I put the two nodes in one file than all is well.
>
> I've noticed that after loading, both nodes are in the 'nodes' table, but not in 
> the 'current_nodes' table, making me think that the error occurs there.
> But I can't figure out why.
>   
I don't know what is causing your error.  Sorry if the following 
suggestions are obvious but they're the only reasons I know of that 
might be causing your error.:
1. Make sure the database is empty before starting the import.  Use the 
--truncate-mysql task to delete data from tables used by osmosis.
2. Make sure you are actually importing the two separate files and not 
the same file twice.

Having said that, it is not typical to import two files separately into 
the database and it isn't something I test so there could be some reason 
why this doesn't work that I'm not aware of.  The typical way of 
importing two different files is to merge them first using the --merge 
task.  The way of updating a database after an import is via changesets 
and the --write-mysql-change task.

FYI, the current_nodes table is always populated last and this will only 
be done if everything else is successful.  The normal nodes table is 
populated then when that is completed osmosis copies data from one table 
to the other using bulk sql statements.

Brett





More information about the dev mailing list