]> git.openstreetmap.org Git - nominatim.git/commitdiff
reduce limits on high loads and order results correctly
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 24 Aug 2012 23:24:57 +0000 (01:24 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 24 Aug 2012 23:24:57 +0000 (01:24 +0200)
utils/cron_banip.sh

index c73db5600dfebfc1eab3ebdc45d34ed7759b0b51..2e0c8dfb60d51d0d781a27d3641b53082e296e25 100755 (executable)
@@ -23,6 +23,11 @@ SRCHSHORT_LIMIT='10 min'
 
 PSQLCMD='psql -qtA -d nominatim'
 
+curload=`cat /proc/loadavg | sed 's:[. ].*::'`
+if [ "$curload" -gt "15" ]; then
+  REVSHORT_LIMIT=$((REVSHORT_LIMIT/2))
+fi
+
 # Blocking candidates
 $PSQLCMD > $BLOCKEDFILE.newblocks << ENDOFQUERY
 SELECT ipaddress FROM
@@ -70,10 +75,12 @@ if [ "x$blocked" == "x" ]; then
   mv $BLOCKEDFILE.newblocks $BLOCKEDFILE 
 else
     $PSQLCMD > $BLOCKEDFILE.newlifted << ENDOFQUERY
+    SELECT column1 FROM (
     VALUES ('$blocked')
     EXCEPT
     (SELECT DISTINCT ipaddress FROM new_query_log
      WHERE starttime > now() - interval '$COOLOFF_PERIOD')
+    ) as q ORDER BY column1;
 ENDOFQUERY
 
     no_lifted=`cat $BLOCKEDFILE.newlifted | wc -w`