[Checkins] SVN: Zope/trunk/ During startup open a connection to every configured database, to ensure all of them can indeed be accessed. This avoids surprises during runtime when traversal to some database mountpoint could fail as the underlying storage cannot be opened at all.

Hanno Schlichting hannosch at hannosch.eu
Sun Jul 3 09:07:09 EDT 2011


Log message for revision 122073:
  During startup open a connection to every configured database, to ensure all of them can indeed be accessed. This avoids surprises during runtime when traversal to some database mountpoint could fail as the underlying storage cannot be opened at all.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Zope2/App/startup.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2011-07-03 12:45:58 UTC (rev 122072)
+++ Zope/trunk/doc/CHANGES.rst	2011-07-03 13:07:09 UTC (rev 122073)
@@ -16,6 +16,11 @@
 Features Added
 ++++++++++++++
 
+- During startup open a connection to every configured database, to ensure all
+  of them can indeed be accessed. This avoids surprises during runtime when
+  traversal to some database mountpoint could fail as the underlying storage
+  cannot be opened at all.
+
 - Explicitly close all databases on shutdown, which ensures `Data.fs.index`
   gets written to the file system.
 

Modified: Zope/trunk/src/Zope2/App/startup.py
===================================================================
--- Zope/trunk/src/Zope2/App/startup.py	2011-07-03 12:45:58 UTC (rev 122072)
+++ Zope/trunk/src/Zope2/App/startup.py	2011-07-03 13:07:09 UTC (rev 122073)
@@ -93,6 +93,17 @@
         else:
             DB = ZODB.DB(m.Storage, databases=databases)
 
+    # Force a connection to every configured database, to ensure all of them
+    # can indeed be opened. This avoids surprises during runtime when traversal
+    # to some database mountpoint fails as the underlying storage cannot be
+    # opened at all
+    for mount, name in dbtab.listMountPaths():
+        _db = dbtab.getDatabase(mount)
+        _conn = _db.open()
+        _conn.close()
+        del _conn
+        del _db
+
     notify(DatabaseOpened(DB))
 
     Globals.BobobaseName = DB.getName()



More information about the checkins mailing list