]> git.openstreetmap.org Git - nominatim.git/commitdiff
disable JIT and parallel execution for osm2pgsql updates again
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 16 Feb 2021 14:05:14 +0000 (15:05 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 16 Feb 2021 17:23:47 +0000 (18:23 +0100)
The gazetteer output doesn't disable these functions when
writing to the place table but the triggers may contain
operations that cause misplanning for the query planner.

nominatim/db/connection.py
nominatim/tools/exec_utils.py
nominatim/tools/replication.py

index 4d30151d7f20acb8d4e8e8a18e2d1d5e8856d5fb..c7e22c98e500c7d53936fad88fa77a8bdd3fad7f 100644 (file)
@@ -50,6 +50,15 @@ class _Connection(psycopg2.extensions.connection):
                                 WHERE tablename = %s""", (table, ))
             return num == 1
 
+    def server_version_tuple(self):
+        """ Return the server version as a tuple of (major, minor).
+            Converts correctly for pre-10 and post-10 PostgreSQL versions.
+        """
+        version = self.server_version
+        if version < 100000:
+            return (version / 10000, (version % 10000) / 100)
+
+        return (version / 10000, version % 10000)
 
 def connect(dsn):
     """ Open a connection to the database using the specialised connection
index 541a2b08f05b563b47272795ef82b6239e21413a..f373f347dd23936fd155edda465373fcb09e42d4 100644 (file)
@@ -127,6 +127,9 @@ def run_osm2pgsql(options):
         if param in dsn:
             cmd.extend(('--' + param, dsn[param]))
 
+    if options.get('disable_jit', False):
+        env['PGOPTIONS'] = '-c jit=off -c max_parallel_workers_per_gather=0'
+
     cmd.append(str(options['import_file']))
 
     subprocess.run(cmd, cwd=options.get('cwd', '.'), env=env, check=True)
index a3ef84fef7214c7e865d4e9b6af539bc7e5d9f6e..a0a741e8ff4ae87155ff38853784d1af41b66ce3 100644 (file)
@@ -115,6 +115,7 @@ def update(conn, options):
 
     # Consume updates with osm2pgsql.
     options['append'] = True
+    options['disable_jit'] = conn.server_version_tuple() >= (11, 0)
     run_osm2pgsql(options)
 
     # Write the current status to the file