[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] ocitysmap patch: set session statement timeout

From: David Decotigny
Subject: [Maposmatic-dev] ocitysmap patch: set session statement timeout
Date: Thu, 07 Jan 2010 00:00:43 +0100
User-agent: Thunderbird (X11/20090817)


2mn to prepare the patch, 45mn to fight with git without success... Giving up. I'm sending the patch by hand => attached.

Note that I manually patched prod and dev on the server but did NOT commit the changes to any branch there to avoid possible git headaches. Thomas, I let you manage this the cleanest way (git reset --hard + deploy ?).

The patch sets the statement_timeout parameter for the ocitysmap sessions to 18mn. This should be enough. I checked that an exception is raised when the timeout appears (=> ocitysmap crashes immediatly). The other sessions (eg. osm2pgsql) should not be affected. Issue "show statement_timeout" on a new DB connection to make sure (should reply '0').

Restarted daemon on prod and dev. Made sure that a few renderings could be completed on prod and dev.

This is a "quick and dirty fix": the timeout should be configurable from a config file or from the cmdline. For now it's hard-coded in Will submit a task entry to savannah about that.

diff --cc ocitysmap-render
index 538dff4,d0800af..0000000
--- a/ocitysmap-render
+++ b/ocitysmap-render
diff --git a/ocitysmap/ b/ocitysmap/
index 15f079f..50d8c1a 100644
--- a/ocitysmap/
+++ b/ocitysmap/
@@ -32,6 +32,7 @@ import map_canvas, grid, utils
 from draw_utils import enclose_in_frame
 LOG = logging.getLogger('ocitysmap')
 class BaseOCitySMapError(Exception):
     """Base class for exceptions thrown by OCitySMap."""
@@ -294,6 +295,16 @@ class OCitySMap:
                           datasource['password'], datasource['host'],
+        # Set session timeout parameter (18mn)
+        cursor = db.cursor()
+        cursor.execute("show statement_timeout;")
+        LOG.debug("Initial statement timeout: %s" % cursor.fetchall()[0][0])
+        cursor.execute("set session statement_timeout=%d;"
+                       % (STATEMENT_TIMEOUT_MINUTES*60*1000))
+        cursor.execute("show statement_timeout;")
+"Configured statement timeout: %s" % cursor.fetchall()[0][0])
+        del cursor
         if self.city_name:
             self.boundingbox = self.find_bounding_box_by_name(db, 
         elif self.osmid:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]