Osm2pgsql-replication update error planet_osm_point table does not exist


I am trying to update a postgis database previously imported with osm2pgsql using the osm2pgsql-replication feature but i get an error. I am using osm2pgsql version 1.8.0

What i have done:

  • imported from pbf file using this command:
    $osm2pgsqlCmd = “PGPASSWORD=$dbPassword osm2pgsql -c -d $dbName -H ‘db’ -U $dbUser -O flex -x -S $luaPath $pbfPath --slim”;
    This command create the relative table in my database, along with the ‘planet_osm_nodes’, ‘planet_osm_ways’ and ‘planet_osm_rels’ tables.

  • initialized the replication using this command:
    PGPASSWORD=$password osm2pgsql-replication init -d $database -H db -U $user
    this command creates a ‘planet_osm_replication_status’ table in my database with url, sequence and importdate columns needed for the update.

  • run the command for the update:
    PGPASSWORD=$passeord osm2pgsql-replication update -d $database -H db -U $user
    This throws error:
    ERROR: Database error: ERROR: relation “planet_osm_point” does not exist
    LINE 1: PREPARE get_wkb(int8) AS SELECT way FROM “planet_osm_point” …

Effectively i have no planet_osm_point table in my database because it was not created when importing from pbf.

What am i missing here?

Thanks for the attention :slight_smile:

You probably need to specify at least some of the osm2pgsql options you used during the initial import when doing the replication - try something like:

PGPASSWORD=$password osm2pgsql-replication init -d $database -H db -U $user -- -O flex -c -x -S $luaPath --slim

They’re probably not all needed but they shouldn’t hurt so long as they’re the same.

Thank you, it worked like this:
PGPASSWORD=$password osm2pgsql-replication update -d $database -H db -U $user – -O flex -x -S $luapath --slim

but i have a question: what if i have multiple tables (created with different lua files) to keep updated? Running the previous command with admin_areas.lua the output was:

2024-03-25 12:04:25 [INFO]: Using replication service ‘Index of /europe/italy/centro-updates’. Current sequence 3048 (2024-03-04 21:21:35+00:00).
2024-03-25 12:07:59 Done postprocessing on table ‘planet_osm_nodes’ in 0s
2024-03-25 12:07:59 Done postprocessing on table ‘planet_osm_ways’ in 0s
2024-03-25 12:07:59 Done postprocessing on table ‘planet_osm_rels’ in 0s
2024-03-25 12:07:59 All postprocessing on table ‘admin_areas’ done in 0s.
2024-03-25 12:07:59 osm2pgsql took 193s (3m 13s) overall.
2024-03-25 12:07:59 [INFO]: Data imported until 2024-03-24 21:21:29+00:00. Backlog remaining: 13:46:30.928081

I see that only the admin_areas table was updated, but the importdate column in my ‘planet_osm_replication_status’ was updated and due to this if i run again the command with a different lua file i get:

2024-03-25 12:08:43 [INFO]: Using replication service ‘Index of /europe/italy/centro-updates’. Current sequence 3068 (2024-03-24 21:21:29+00:00).
2024-03-25 12:08:43 [INFO]: Database already up-to-date.

If you have several “independent” imports in the same database you can use multiple schemas to keep them separate. But this is kind of error prone and schema handling changed in recent versions, refer to the manual for all the details.

You might want to look at the Themepark framework which allows you to have multiple configurations nicely separated but use them together.