[Zope-CVS] CVS: Products/DBTab - CHANGES.txt:1.10 Mount.py:1.8 MountedObject.py:1.7

Shane Hathaway shane@zope.com
Wed, 11 Jun 2003 17:54:28 -0400


Update of /cvs-repository/Products/DBTab
In directory cvs.zope.org:/tmp/cvs-serv28232

Modified Files:
	CHANGES.txt Mount.py MountedObject.py 
Log Message:
Fixed a race condition on connection close.

The root connection was returned to the pool before the mounted
connections were closed.  If another thread pulled the root connection
out of the pool before the original thread finished closing mounted
connections, when the original thread got control back it closed the
mounted connections even though the new thread was using them.  The
symptom was spurious "Should not load state when connection closed"
errors under high load.

Also began unit tests.



=== Products/DBTab/CHANGES.txt 1.9 => 1.10 ===
--- Products/DBTab/CHANGES.txt:1.9	Fri Apr 18 22:15:29 2003
+++ Products/DBTab/CHANGES.txt	Wed Jun 11 17:53:58 2003
@@ -1,4 +1,14 @@
 
+Next Release
+
+  - Fixed a race condition on connection close.  The symptom was
+    spurious "Should not load state when connection closed" errors under
+    high load.
+
+  - DemoStorage configurations can now include a base_type option,
+    taking advantage of DemoStorage's layering feature.
+
+
 Version 1.2
 
   - Fixed activity monitoring for mounted databases.


=== Products/DBTab/Mount.py 1.7 => 1.8 ===
--- Products/DBTab/Mount.py:1.7	Fri Apr 18 22:27:12 2003
+++ Products/DBTab/Mount.py	Wed Jun 11 17:53:58 2003
@@ -180,7 +180,8 @@
                 conn._setDB(conn._db)
 
     def close(self):
-        self._real_close()
+        if self._root_connection is not None:
+            raise RuntimeError("Should not close mounted connections directly")
         conns = self._mounted_connections
         if conns:
             for conn in conns.values():
@@ -197,6 +198,16 @@
                 conn._debug_info = ()
                 # The mounted connection keeps a reference to
                 # its database, but nothing else.
+                # Note that mounted connections can not operate
+                # independently, so don't use _closeConnection() to
+                # return them to the pool.  Only the root connection
+                # should be returned.
+        # Close this connection only after the mounted connections
+        # have been closed.  Otherwise, this connection gets returned
+        # to the pool too early and another thread might use this
+        # connection before the mounted connections have all been
+        # closed.
+        self._real_close()
 
 if 1:
     # patch Connection.py.


=== Products/DBTab/MountedObject.py 1.6 => 1.7 ===
--- Products/DBTab/MountedObject.py:1.6	Fri Apr 18 22:15:29 2003
+++ Products/DBTab/MountedObject.py	Wed Jun 11 17:53:58 2003
@@ -39,6 +39,10 @@
         from MainConfiguration import configuration
     return configuration
 
+def setConfiguration(c):
+    global configuration
+    configuration = c
+
 
 class SimpleTrailblazer:
     """Follows Zope paths.  If a path is not found, creates a Folder.