]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/index.c
stop treating capital cities as villages, memory leak on deadlock
[nominatim.git] / nominatim / index.c
index 5d10994cc465cfe6043e65235b163bd92162445d..55f3c578f55b73b0aaadb59d81e8686dbb46e9b4 100644 (file)
@@ -343,13 +343,14 @@ void *nominatim_indexThread(void * thread_data_in)
 
         updateStartTime = time(0);
        int done = 0;
 
         updateStartTime = time(0);
        int done = 0;
+
+        if (thread_data->writer)
+        {
+             nominatim_exportPlaceQueries(place_id, thread_data->conn, &querySet);
+        }
+
        while(!done)
        {
        while(!done)
        {
-             if (thread_data->writer)
-             {
-                 nominatim_exportPlaceQueries(place_id, thread_data->conn, &querySet);
-             }
-
 
                paramPlaceID = PGint32(place_id);
                paramValues[0] = (char *)&paramPlaceID;
 
                paramPlaceID = PGint32(place_id);
                paramValues[0] = (char *)&paramPlaceID;
@@ -363,12 +364,14 @@ void *nominatim_indexThread(void * thread_data_in)
                        if (strncmp(PQerrorMessage(thread_data->conn), "ERROR:  deadlock detected", 25))
                        {
                            fprintf(stderr, "index_placex: UPDATE failed - deadlock, retrying\n");
                        if (strncmp(PQerrorMessage(thread_data->conn), "ERROR:  deadlock detected", 25))
                        {
                            fprintf(stderr, "index_placex: UPDATE failed - deadlock, retrying\n");
+                           PQclear(res);
+                            sleep(rand() % 10);
                        }
                        else
                        {
                            fprintf(stderr, "index_placex: UPDATE failed: %s", PQerrorMessage(thread_data->conn));
                            PQclear(res);
                        }
                        else
                        {
                            fprintf(stderr, "index_placex: UPDATE failed: %s", PQerrorMessage(thread_data->conn));
                            PQclear(res);
-                               sleep(5);
+                            sleep(rand() % 10);
 //                         exit(EXIT_FAILURE);
                        }
                }
 //                         exit(EXIT_FAILURE);
                        }
                }