Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nominatim updates are stuck after "Processed relations" #3445

Closed
ArvyRogerio opened this issue Jun 16, 2024 · 27 comments · Fixed by #3447
Closed

Nominatim updates are stuck after "Processed relations" #3445

ArvyRogerio opened this issue Jun 16, 2024 · 27 comments · Fixed by #3447

Comments

@ArvyRogerio
Copy link

ArvyRogerio commented Jun 16, 2024

Describe the bug
No docker (self host).
Since 2 weeks ago, "nominatim replication --once" is not completing.
Tried to full reinstall, same results.
First server was up +1 year, update every 2:00 AM.
Postgres appears to be in loop (COPY). More than 24 hours running.
Only one country (Brazil).

2024-06-16 16:57:45: Using project directory: /dados/nominatim/nominatim-planet
2024-06-16 16:58:20 osm2pgsql version 1.11.0
2024-06-16 16:58:20 Database version: 15.6 (Debian 15.6-0+deb12u1)
2024-06-16 16:58:20 PostGIS version: 3.3
2024-06-16 16:58:20 Loading properties from table '"public"."osm2pgsql_properties"'.
2024-06-16 16:58:20 Not using flat node file (same as on import).
2024-06-16 16:58:20 Using prefix 'planet_osm' (same as on import).
2024-06-16 16:58:20 Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).
2024-06-16 17:02:45 Reading input files done in 265s (4m 25s).
2024-06-16 17:02:45 Processed 201681 nodes in 56s - 4k/s
2024-06-16 17:02:45 Processed 40896 ways in 188s (3m 8s) - 218/s
2024-06-16 17:02:45 Processed 4733 relations in 21s - 225/s
(Control+C)
KeyboardInterrupt

Postgres 15:

3351778 postgres 87.6 6.7 218:32.43 postgres: 15/main: nominatim nominatim 127.0.0.1(54044) COPY
(for more than 24 Hours - needed to restart postgres)

To Reproduce
nominatim replication --once

Software Environment (please complete the following information):

  • Nominatim version: 4.4.0
  • Postgresql version: 15
  • Postgis version: 3? (not sure)
  • OS: Ubuntu 22.04

Hardware Configuration (please complete the following information):

  • RAM: 32 Gb
  • number of CPUs: 8
  • type and size of disks: 2 Tb SATA
@ArvyRogerio
Copy link
Author

ArvyRogerio commented Jun 16, 2024

Script:

#!/bin/bash

NOMINATIM_REPLICATION_URL="http://download.geofabrik.de/south-america/brazil-updates"
NOMINATIM_REPLICATION_UPDATE_INTERVAL=86400
NOMINATIM_REPLICATION_RECHECK_INTERVAL=900

cd /dados/nominatim/nominatim-planet
nominatim replication --once

@mtmail
Copy link
Collaborator

mtmail commented Jun 16, 2024

Can you post relevant lines from the postgresql server log? -> we're looking for errors, warnings, out-of-memory or such.

What does the query SELECT * FROM pg_stat_activity print? (pg_top is also a nice tool but shows less information). -> We're looking for possible queries that block updates.

What is the output of nominatim replication --check-for-updates? -> To check how many days the database is behind.

@ArvyRogerio
Copy link
Author

ArvyRogerio commented Jun 17, 2024

pSQL, nothing in special, only when I stopped the script and restarted it.

2024-06-16 17:49:26.154 -03 [3275581] LOG: checkpoint complete: wrote 168 buffers (0.1%); 0 WAL file(s) added, 1 removed, 19 recycled; write=212.440 s, sync=6.113 s, total=224.596 s; sync files=35, longest=0.877 s, average=0.175 s; distance=336736 kB, estimate=437388 kB
2024-06-16 17:49:57.452 -03 [3275579] LOG: received fast shutdown request
2024-06-16 17:49:57.701 -03 [3275579] LOG: aborting any active transactions
2024-06-16 17:49:57.709 -03 [3351778] nominatim@nominatim FATAL: terminating connection due to administrator command
2024-06-16 17:49:57.709 -03 [3351778] nominatim@nominatim CONTEXT: SQL statement "update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter)"
PL/pgSQL function placex_insert() line 99 at SQL statement
SQL statement "INSERT INTO placex (osm_type, osm_id, class, type, name,
admin_level, address, extratags, geometry)
VALUES (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type, NEW.name,
NEW.admin_level, NEW.address, NEW.extratags, NEW.geometry)"
PL/pgSQL function place_insert() line 188 at SQL statement
COPY place, line 319: "W 6176613 highway residential 15 "name"=>"Woodhouse Cliff" \N \N 0102000020E610000005000000753348669..."
2024-06-16 17:49:57.709 -03 [3351778] nominatim@nominatim STATEMENT: COPY "public"."place" ("osm_type","osm_id","class","type","admin_level","name","address","extratags","geometry") FROM STDIN
2024-06-16 17:49:57.709 -03 [3348231] nominatim@nominatim FATAL: terminating connection due to administrator command
2024-06-16 17:49:57.709 -03 [3348234] nominatim@nominatim FATAL: terminating connection due to administrator command
2024-06-16 17:49:57.926 -03 [3275579] LOG: background worker "logical replication launcher" (PID 3275586) exited with exit code 1
2024-06-16 17:49:58.115 -03 [3275581] LOG: shutting down
2024-06-16 17:49:58.180 -03 [3275581] LOG: checkpoint starting: shutdown immediate
2024-06-16 17:50:04.192 -03 [3275581] LOG: checkpoint complete: wrote 405 buffers (0.2%); 0 WAL file(s) added, 3 removed, 7 recycled; write=1.865 s, sync=3.610 s, total=6.077 s; sync files=33, longest=0.675 s, average=0.110 s; distance=165306 kB, estimate=410180 kB
2024-06-16 17:50:04.706 -03 [3275579] LOG: database system is shut down

@ArvyRogerio
Copy link
Author

ArvyRogerio commented Jun 17, 2024

nominatim@server:~/nominatim-planet$ nominatim replication --check-for-updates
2024-06-16 21:06:11: Using project directory: /dados/nominatim/nominatim-planet
2024-06-16 21:06:12: New data available (6133423 => 6136455).

@ArvyRogerio
Copy link
Author

SELECT * FROM pg_stat_activity
No records.

@lonvia
Copy link
Member

lonvia commented Jun 17, 2024

This is an issue with the recent vandalism on OpenStreetMap. To work around this:

  • stop the currently running updates
  • kill the ongoing copy operation
  • run NOMINATIM_REPLICATION_MAX_DIFF=10000 nominatim replication --catch-up to get past the offending changes
  • restart your update process

Further note that the vandalism issues are only present in the minutely and hourly diffs of planet replication. The daily diffs from the planet and Geofabrik should not be affected. Your setup is configured wrongly and consumes planet-wide diffs. In particular, in your bash script you need to set export NOMINATIM_REPLICATION_URL="http://download.geofabrik.de/south-america/brazil-updates". Without the 'export', the setting will not be picked up by the nominatim executable.

@ArvyRogerio
Copy link
Author

Hi @lonvia, thanks, I'll retry today and get back to you.

BTW, I found the "old server" script log (that was running +1 year fine). That was a PG 13.

2024-06-14 02:31:01: Using project directory: /srv/nominatim
2024-06-14 02:32:47 osm2pgsql version 1.5.1
2024-06-14 02:32:47 Database version: 13.14 (Debian 13.14-0+deb11u1)
2024-06-14 02:32:47 PostGIS version: 3.1
2024-06-14 02:32:47 Parsing gazetteer style file '/usr/local/etc/nominatim/import-extratags.style'.
Processing: Node(150k 150.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(1k 0.25k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(2k 0.40k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(4k 0.67k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(6k 0.86k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(8k 1.00k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(11k 1.22k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(18k 1.80k/s) Relation(0 0.0/s) Processing: Node(228k 9.5k/s) Way(30k 1.15k/s) Relation(10 10.0/s) Processing: Node(228k 9.5k/s) Way(30k 1.15k/s) Relation(60 60.0/s) Processing: Node(228k 9.5k/s) Way(30k 1.15k/s) Relation(1000 500.0/s) > 2024-06-14 02:33:50 Reading input files done in 63s (1m 3s).
2024-06-14 02:33:50 Processed 228543 nodes in 24s - 10k/s
2024-06-14 02:33:50 Processed 30306 ways in 26s - 1k/s
2024-06-14 02:33:50 Processed 1862 relations in 13s - 143/s
2024-06-15 01:58:49 ERROR: DB copy thread failed: Ending COPY mode for 'place' failed: FATAL: terminating connection due to administrator command
CONTEXT: SQL statement "update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter)"
PL/pgSQL function placex_insert() line 96 at SQL statement
SQL statement "insert into placex (osm_type, osm_id, class, type, name,
admin_level, address, extratags, geometry)
values (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type, NEW.name,
NEW.admin_level, NEW.address, NEW.extratags, NEW.geometry)"
PL/pgSQL function place_insert() line 166 at SQL statement
COPY place, line 243: "4430214 W highway residential "name"=>"Agar Street" 15 \N "motor_vehicle"=>"destination","surface"=>..."
.
2024-06-15 01:58:49 Done postprocessing on table 'planet_osm_nodes' in 0s
2024-06-15 01:58:49 Done postprocessing on table 'planet_osm_ways' in 0s
2024-06-15 01:58:49 Done postprocessing on table 'planet_osm_rels' in 0s
Traceback (most recent call last):
File "/usr/local/bin/nominatim", line 11, in
exit(cli.nominatim(module_dir='/usr/local/lib/nominatim/module',
File "/usr/local/lib/nominatim/lib-python/nominatim/cli.py", line 235, in nominatim
return parser.run(**kwargs)
File "/usr/local/lib/nominatim/lib-python/nominatim/cli.py", line 96, in run
return args.command.run(args)
File "/usr/local/lib/nominatim/lib-python/nominatim/clicmd/replication.py", line 187, in run
UpdateReplication._update(args)
File "/usr/local/lib/nominatim/lib-python/nominatim/clicmd/replication.py", line 144, in _update
state = replication.update(conn, params)
File "/usr/local/lib/nominatim/lib-python/nominatim/tools/replication.py", line 119, in update
run_osm2pgsql(options)
File "/usr/local/lib/nominatim/lib-python/nominatim/tools/exec_utils.py", line 139, in run_osm2pgsql
subprocess.run(cmd, cwd=options.get('cwd', '.'),
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/lib/nominatim/osm2pgsql', '--hstore', '--latlon', '--slim', '--with-forward-dependencies', 'false', '--log-progress', 'true', '--number-processes', '1', '--cache', '2000', '--output', 'gazetteer', '--style', '/usr/local/etc/nominatim/import-extratags.style', '--append', '/srv/nominatim/osmosischange.osc']' returned non-zero exit status 2.

@driade
Copy link

driade commented Jun 17, 2024

Hi, hello.

Same behaviour here with the Spain and Germany maps since yesterday update at 4 AM. The Portugal update also had some problems but the machines returned to a good state after a few hours.

I'm using https://github.com/mediagis/nominatim-docker

@lonvia
Copy link
Member

lonvia commented Jun 17, 2024

Same remedy if the geofabrik daily diffs cause issues. Stop updates, kill copy (or simply restart postgres), run catch-up with a very large replication size.

@ArvyRogerio
Copy link
Author

@lonvia question: I need to run "NOMINATIM_REPLICATION_MAX_DIFF=10000 nominatim replication --catch-up" only once and, after completed, run my daily-script normally (adding "export" in the 3 constants)?

"NOMINATIM_REPLICATION_MAX_DIFF=10000 nominatim replication --catch-up" is just to fix this or I need to run more times?

My need is update once per day.

@lonvia
Copy link
Member

lonvia commented Jun 17, 2024

The "catch-up" ensures that you jump over the problematic edits in the updates. It only needs to be done once and then updates can continue as usual. (Until the next time it gets stuck, that is. The vandalism is sadly still not completely contained.)

As for your use of planet updates: I suggest that you reimport the Brasil extract and start again from there. The year of applying planet updates will have added a lot of garbage to your database.

@ArvyRogerio
Copy link
Author

ArvyRogerio commented Jun 17, 2024

@lonvia thanks, I did't know about the "export" in the daily script... so, basically I can drop the database, redo the:

nominatim import --osm-file <path>/brazil-latest.osm.pbf

and then just run daily:

#!/bin/bash

export NOMINATIM_REPLICATION_URL="http://download.geofabrik.de/south-america/brazil-updates"
export NOMINATIM_REPLICATION_UPDATE_INTERVAL=86400
export NOMINATIM_REPLICATION_RECHECK_INTERVAL=3600

cd /dados/nominatim/nominatim-planet
nominatim replication --once

It's ok then? I only will use Brazil data.

@mtmail
Copy link
Collaborator

mtmail commented Jun 17, 2024

@ArvyRogerio That looks good.

@lonvia lonvia pinned this issue Jun 18, 2024
@lonvia lonvia changed the title Update (nominatim replication --once): Postgres loop? Nominatim updates are stuck after "Processed relations" Jun 18, 2024
@ArvyRogerio
Copy link
Author

ArvyRogerio commented Jun 18, 2024

Done. Re-imported and ran the update script. For now, looks fine. BTW, no more errors.
Thanks a lot for your help. I'll monitor for some days.

nominatim@server:~$ ./nominatim-updater
2024-06-18 15:05:57: Using project directory: /dados/nominatim/nominatim-planet
2024-06-18 15:06:03: Update completed. Import: 0:00:00. Total: 0:00:00. Remaining backlog: 2 days, 0:46:31.

@Zverik
Copy link

Zverik commented Jul 8, 2024

I have imported the planet on 2 July (240624), and the import still hangs on reading the osmchange. I've used all the suggestions from this thread. Nominatim 4.3.2 (rn updating to 4.4.0 to see how it goes).

Could you maybe release 4.4.1 with the fix?..

@Zverik
Copy link

Zverik commented Jul 8, 2024

Updated to 4.4.0, still get the same:

izverev@Ubuntu-2204-jammy-amd64-base:/srv/nominatim$ NOMINATIM_REPLICATION_MAX_DIFF=10000 sudo -u www-data nominatim replication --catch-up --threads 20
sudo: unable to resolve host Ubuntu-2204-jammy-amd64-base: Name or service not known
[sudo] password for izverev: 
2024-07-08 19:15:35: Using project directory: /srv/nominatim
2024-07-08 19:15:39  osm2pgsql version 1.11.0
2024-07-08 19:15:39  Database version: 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
2024-07-08 19:15:39  PostGIS version: 3.2
2024-07-08 19:15:39  Loading properties from table '"public"."osm2pgsql_properties"'.
2024-07-08 19:15:39  Using flat node file '/srv/nominatim/flatnodes.bin' (same as on import).
2024-07-08 19:15:39  Using prefix 'planet_osm' (same as on import).
2024-07-08 19:15:39  Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).
Processing: Node(420k 420.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)

(and stuck on this line and count).

(I made #3470).

@Zverik
Copy link

Zverik commented Jul 11, 2024

So with 4.3.2 neither big nor small max_diff helped. First try I stopped after 22 hours:

$ NOMINATIM_REPLICATION_MAX_DIFF=10000 sudo -u www-data nominatim replication --catch-up                                     
2024-07-10 18:07:16: Using project directory: /srv/nominatim                                                                                                                                         
2024-07-10 18:07:19  osm2pgsql version 1.9.2                                                                                                                                                         
2024-07-10 18:07:19  Database version: 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)                                                                                                                         
2024-07-10 18:07:19  PostGIS version: 3.2                                                                                                                                                            
2024-07-10 18:07:19  Loading properties from table '"public"."osm2pgsql_properties"'.                                                                                                                
2024-07-10 18:07:19  Using flat node file '/srv/nominatim/flatnodes.bin' (same as on import).                                                                                                        
2024-07-10 18:07:19  Using prefix 'planet_osm' (same as on import).                                                                                                                                  
2024-07-10 18:07:19  Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).                                                            
2024-07-10 18:07:52  Reading input files done in 33s.                                                                                                                                                
2024-07-10 18:07:52    Processed 154409 nodes in 10s - 15k/s                                                                                                                                         
2024-07-10 18:07:52    Processed 30198 ways in 14s - 2k/s                                                                                                                                            
2024-07-10 18:07:52    Processed 1817 relations in 9s - 202/s 

Second try started 3 hours ago, don't think it'll end:

$ NOMINATIM_REPLICATION_MAX_DIFF=500 sudo -u www-data nominatim replication --catch-up
2024-07-11 16:02:21: Using project directory: /srv/nominatim
2024-07-11 16:02:39  osm2pgsql version 1.9.2
2024-07-11 16:02:39  Database version: 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
2024-07-11 16:02:39  PostGIS version: 3.2
2024-07-11 16:02:39  Loading properties from table '"public"."osm2pgsql_properties"'.
2024-07-11 16:02:39  Using flat node file '/srv/nominatim/flatnodes.bin' (same as on import).
2024-07-11 16:02:39  Using prefix 'planet_osm' (same as on import).
2024-07-11 16:02:39  Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).
2024-07-11 16:03:12  Reading input files done in 33s.                                     
2024-07-11 16:03:12    Processed 154409 nodes in 11s - 14k/s
2024-07-11 16:03:12    Processed 30198 ways in 13s - 2k/s
2024-07-11 16:03:12    Processed 1817 relations in 9s - 202/s

Am I missing anything, or it'd be better to reimport from scratch with 4.4.0?

@lonvia
Copy link
Member

lonvia commented Jul 12, 2024

Have you made absolutely sure that no COPY or TRUNCATE operation is in progress before restarting the catch-up? The vandalism leaves a COPY operation ongoing which blocks everything, restarting leaves a TRUNCATE which blocks everything. They both need to be killed separately.

@Zverik
Copy link

Zverik commented Jul 12, 2024

Yes, there was this query ongoing: COPY "public"."place" ("osm_type","osm_id","class","type","admin_level","name","address","extratags","geometry") FROM STDIN. I terminated it both times by hand. So yeah, I'm sure.

@lonvia
Copy link
Member

lonvia commented Jul 12, 2024

Two possible explanations then: (a) part of the vandalism already got committed, so this is actually doing the reverts or (b) doing the large diff lands you again in the middle of the next vandalism wave. Either way, a reimport might be in order.

If you don't mind experimenting a bit, could you apply #3447 and see if that makes updates go through? The patch should be appliable to your 4.3.2 version. If it helps, I'll do a 4.4.1 release with this fix. Note that you still have to reimport if your current state is (a). The database will be likely messed up badly if the vandalised ways got through.

Edit: after applying the patch, you need to run nominatim refresh --functions to load the changes into the database.

@RailsGuy
Copy link

I've also had this problem (on v4.3.2.) and attempting to catch up as suggested with max diff 10000. I'm concerned my database may be "messed up badly if the vandalised ways got through". How can I find out if my database has been corrupted?

@lonvia
Copy link
Member

lonvia commented Jul 30, 2024

If the catch-up goes through, you are fine.

Otherwise you can try running the query SELECT max(ST_Length(geometry)) FROM placex WHERE rank_address = 26 and ST_GeometryType(geometry) = 'ST_LineString'. If the result is larger than 20, then you likely have some vandalism ways in there.

Warning: the following is only for experienced users.

You could try to get rid of them with UPDATE placex SET indexed_status = 100 WHERE rank_address = 26 and ST_GeometryType(geometry) = 'ST_LineString' and ST_Length(geometry) > 20 followed by running nominatim index. However, there are no guarantees that it will work. You want the patch from #3447 before trying it.

@RailsGuy
Copy link

RailsGuy commented Aug 2, 2024

Thanks for the suggestions. It looks like the update is stuck again but I'll wait a little longer. Details below

If it is stuck I guess I'll need to reload the database?
Is there anything else I should do to avoid this in the future? I have v4.3.2 installed.

The original problem from June


2024-06-01 06:50:52: Using project directory: /srv/nominatim
2024-06-01 06:51:07  osm2pgsql version 1.9.2
2024-06-01 06:51:07  Database version: 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
2024-06-01 06:51:07  PostGIS version: 3.2
2024-06-01 06:51:07  Loading properties from table '"public"."osm2pgsql_properties"'.
2024-06-01 06:51:07  Using flat node file '/var/lib/postgresql/Nominatim/flatnode.file' (same as on import).
2024-06-01 06:51:07  Using prefix 'planet_osm' (same as on import).
2024-06-01 06:51:07  Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).
^MProcessing: Node(10k 10.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)^MProcessing: Node(30k 15.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)^MProcessing: Node(60k 20.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)^MProcessing: Node(70k 17.
5k/s) Way(0k 0.00k/s) Relation(0 0.0/s)^MProcessing: Node(180k 36.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(1k 1.00k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(3k 1.50k/s) Rel
ation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(4k 1.33k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(5k 1.25k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(7k 1.40k/s) Relation(0 0.0/s)^MProcessing
: Node(339k 6.9k/s) Way(8k 1.33k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(10k 1.43k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(13k 1.62k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(
16k 1.78k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(18k 1.80k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(24k 2.18k/s) Relation(0 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(29k 2.42k/s) Relation(0
 0.0/s)^MProcessing: Node(339k 6.9k/s) Way(61k 1.49k/s) Relation(10 10.0/s)^MProcessing: Node(339k 6.9k/s) Way(61k 1.49k/s) Relation(20 20.0/s)^MProcessing: Node(339k 6.9k/s) Way(61k 1.49k/s) Relation(340 170.0/s)^MProces
sing: Node(339k 6.9k/s) Way(61k 1.49k/s) Relation(940 313.3/s)^M                                                                                          ^M2024-06-01 06:52:58  Reading input files done in 111s (1m 51s).
2024-06-01 06:52:58    Processed 339992 nodes in 49s - 7k/s
2024-06-01 06:52:58    Processed 61529 ways in 41s - 2k/s
2024-06-01 06:52:58    Processed 2105 relations in 21s - 100/s

^CTraceback (most recent call last):
  File "/usr/local/bin/nominatim", line 12, in <module>
    exit(cli.nominatim(module_dir='/usr/local/lib/nominatim/module',
  File "/usr/local/lib/nominatim/lib-python/nominatim/cli.py", line 225, in nominatim
    return get_set_parser().run(**kwargs)
  File "/usr/local/lib/nominatim/lib-python/nominatim/cli.py", line 121, in run
    return args.command.run(args)

applying the patch to placex_triggers.sql

I eventually found the file in the location below (ubuntu) and confirmed that 'nominatim refresh --functions' applied the change to the database.
/usr/local/lib/nominatim/lib-sql/functions

Queries

Looks OK, Result less than 20 and no records to update.

nominatim=# SELECT max(ST_Length(geometry)) FROM placex WHERE rank_address = 26 and ST_GeometryType(geometry) = 'ST_LineString';
        max        
-------------------
 9.008037589748708
(1 row)

nominatim=# 

nominatim=# begin;
BEGIN
nominatim=*# UPDATE placex SET indexed_status = 100 WHERE rank_address = 26 and ST_GeometryType(geometry) = 'ST_LineString' and ST_Length(geometry) > 20;
UPDATE 0
nominatim=*# rollback;
ROLLBACK
nominatim=#

Attempt to Catchup

Looks to be stuck again.

NOMINATIM_REPLICATION_MAX_DIFF=10000 nominatim replication -vv --catch-up

...

2024-08-01 11:50:42: Downloaded change 6169140. (23 kB available in download buffer)
2024-08-01 11:50:42: https://planet.openstreetmap.org:443 "GET /replication/minute/006/169/141.osc.gz HTTP/1.1" 302 391
2024-08-01 11:50:42: https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com:443 "GET /planet/replication/minute/006/169/141.osc.gz HTTP/1.1" 200 39969
2024-08-01 11:50:42: Downloaded change 6169141. (-141 kB available in download buffer)
2024-08-01 11:51:28: TRUNCATE place_to_be_deleted
2024-08-01 11:51:28  osm2pgsql version 1.9.2
2024-08-01 11:51:28  Database version: 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
2024-08-01 11:51:28  PostGIS version: 3.2
2024-08-01 11:51:28  Loading properties from table '"public"."osm2pgsql_properties"'.
2024-08-01 11:51:28  Using flat node file '/var/lib/postgresql/Nominatim/flatnode.file' (same as on import).
2024-08-01 11:51:28  Using prefix 'planet_osm' (same as on import).
2024-08-01 11:51:28  Using style file '/usr/local/etc/nominatim/import-extratags.lua' (same as on import).
Processing: Node(24960k 7.4k/s) Way(0k 0.00k/s) Relation(0 0.0/s))

osm2pgsql queries

All started at 2024-08-01 11:51:28 and 2 active copy from STDIN.

 16386 | nominatim |  930389 |            |    16384 | workbooks | osm2pgsql        |             |                 |          -1 | 2024-08-01 11:51:28.154704+00 |                               | 2024-08-01 16:37:44.97756+00  | 2024-08-01 16:37:45.294148+00 | Client          | ClientRead          | idle   |             |              |          | COMMIT                                                                                                                      | client backend
 16386 | nominatim |  930391 |            |    16384 | workbooks | osm2pgsql        |             |                 |          -1 | 2024-08-01 11:51:28.161311+00 | 2024-08-02 05:51:02.194225+00 | 2024-08-02 05:51:02.194225+00 | 2024-08-02 05:51:02.194226+00 | Client          | ClientRead          | active |             |    294557311 |          | COPY "public"."planet_osm_ways" FROM STDIN                                                                                  | client backend
 16386 | nominatim |  930392 |            |    16384 | workbooks | osm2pgsql        |             |                 |          -1 | 2024-08-01 11:51:28.211539+00 |                               | 2024-08-01 11:51:28.222028+00 | 2024-08-01 11:51:28.222077+00 | Client          | ClientRead          | idle   |             |              |          | PREPARE get_rel(int8) AS  SELECT members, tags    FROM "public"."planet_osm_rels" WHERE id = $1                             | client backend
 16386 | nominatim |  930394 |            |    16384 | workbooks | osm2pgsql        |             |                 |          -1 | 2024-08-01 11:51:28.224048+00 | 2024-08-02 05:50:37.049356+00 | 2024-08-02 05:50:37.049356+00 | 2024-08-02 05:50:37.049358+00 |                 |                     | active |   294557311 |    294557311 |          | COPY "public"."place" ("osm_type","osm_id","class","type","admin_level","name","address","extratags","geometry") FROM STDIN | client backend
 16386 | nominatim |  930395 |            |    16384 | workbooks | osm2pgsql        |             |                 |          -1 | 2024-08-01 11:51:28.226104+00 |                               | 2024-08-01 11:51:28.231366+00 | 2024-08-01 11:51:28.231752+00 | Client          | ClientRead          | idle   |             |              |          | DROP TABLE IF EXISTS "public"."place_tmp"                                                                                   | client backend

@martbock
Copy link

martbock commented Aug 9, 2024

This is an issue with the recent vandalism on OpenStreetMap. To work around this:

  • stop the currently running updates

  • kill the ongoing copy operation

  • run NOMINATIM_REPLICATION_MAX_DIFF=10000 nominatim replication --catch-up to get past the offending changes

  • restart your update process

Thanks for the tip! I'm currently trying this, but my server (running a Europe extract) is now on day three of running the catch-up command. @lonvia do you have any experience how long this should take? Even though I'd really like to avoid downtime, maybe a fresh import makes more sense at some point 🤔

CPU usage jumps approx. every hour from ~98% to ~105%, so it still seems to be doing something. Output is stuck at Processing: Node(38766k 1.0k/s) Way(6690k 0.03k/s) Relation(0 0.0/s).

@lonvia
Copy link
Member

lonvia commented Aug 9, 2024

@martbock Given that you now will be 2 months behind on updates, a fresh start sounds more reasonable. It's also a good opportunity to switch to version 4.4 (and eventually the Python frontend).

@lonvia
Copy link
Member

lonvia commented Aug 9, 2024

@RailsGuy I'm out of ideas here. I wouldn't have thought that relations are effected by the vandalism but obviously they are. It might just be that the vandalism has completely messed up Postgres' query planning. I've seen that before. At this point, given that you are now missing 2 months of updates, a reimport (please, do upgrade to 4.4) is advisable.

@martbock
Copy link

martbock commented Aug 9, 2024

@martbock Given that you now will be 2 months behind on updates, a fresh start sounds more reasonable. It's also a good opportunity to switch to version 4.4 (and eventually the Python frontend).

@lonvia all right, that validates my gut feeling. I'll do a fresh import, then. Thanks a lot for your quick input, I appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants