[Zope-Checkins] SVN: Zope/branches/2.12/ Make the maximum number of retries on ConflictError a configuration option.

Tres Seaver tseaver at palladion.com
Sat Apr 17 17:00:05 EDT 2010


Log message for revision 111016:
  Make the maximum number of retries on ConflictError a configuration option.
  
   fixes lp:143013 on this branch
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Zope2/Startup/handlers.py
  U   Zope/branches/2.12/src/Zope2/Startup/tests/test_schema.py
  U   Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml
  U   Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2010-04-17 20:11:19 UTC (rev 111015)
+++ Zope/branches/2.12/doc/CHANGES.rst	2010-04-17 21:00:04 UTC (rev 111016)
@@ -15,6 +15,9 @@
 
   - zope.i18nmessageid = 3.5.1
 
+- LP #143013: make the maximum number of retries on ConflictError a
+  configuration option.
+
 Bugs Fixed
 ++++++++++
 

Modified: Zope/branches/2.12/src/Zope2/Startup/handlers.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/handlers.py	2010-04-17 20:11:19 UTC (rev 111015)
+++ Zope/branches/2.12/src/Zope2/Startup/handlers.py	2010-04-17 21:00:04 UTC (rev 111016)
@@ -207,12 +207,17 @@
 
     # set up trusted proxies
     if config.trusted_proxies:
-        import ZPublisher.HTTPRequest
+        from ZPublisher import HTTPRequest
         # DM 2004-11-24: added host name mapping (such that examples in
         # conf file really have a chance to work
         mapped = []
         for name in config.trusted_proxies: mapped.extend(_name2Ips(name))
-        ZPublisher.HTTPRequest.trusted_proxies = tuple(mapped)
+        HTTPRequest.trusted_proxies = tuple(mapped)
+    
+    # set the maximum number of ConflictError retries
+    if config.max_conflict_retries:
+        from ZPublisher import HTTPRequest
+        HTTPRequest.retry_max_count = config.max_conflict_retries
 
 
 def handleConfig(config, multihandler):

Modified: Zope/branches/2.12/src/Zope2/Startup/tests/test_schema.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/tests/test_schema.py	2010-04-17 20:11:19 UTC (rev 111015)
+++ Zope/branches/2.12/src/Zope2/Startup/tests/test_schema.py	2010-04-17 21:00:04 UTC (rev 111016)
@@ -208,6 +208,19 @@
         self.assertEqual(conf.databases[0].config.connection_class.__name__,
                          'LowConflictConnection')
 
+    def test_max_conflict_retries_default(self):
+        conf, handler = self.load_config_text("""\
+            instancehome <<INSTANCE_HOME>>
+            """)
+        self.assertEqual(conf.max_conflict_retries, 3)
+
+    def test_max_conflict_retries_explicit(self):
+        conf, handler = self.load_config_text("""\
+            instancehome <<INSTANCE_HOME>>
+            max-conflict-retries 15
+            """)
+        self.assertEqual(conf.max_conflict_retries, 15)
+
 def test_suite():
     return unittest.makeSuite(StartupTestCase)
 

Modified: Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml	2010-04-17 20:11:19 UTC (rev 111015)
+++ Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml	2010-04-17 21:00:04 UTC (rev 111016)
@@ -653,6 +653,12 @@
      <metadefault>unset</metadefault>
   </multikey>
 
+  <key name="max-conflict-retries" datatype="integer" default="3" attribute="max_conflict_retries">
+    <description>
+      The maximum number of retries on a conflict error
+    </description>
+  </key>
+
   <key name="security-policy-implementation"
        datatype=".security_policy_implementation"
        default="C">

Modified: Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in	2010-04-17 20:11:19 UTC (rev 111015)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in	2010-04-17 21:00:04 UTC (rev 111016)
@@ -826,6 +826,18 @@
 #
 #    conflict-error-log-level blather
 
+# Directive: max-conflict-retries
+#
+# Description:
+#     Specifies how many times a transaction will be re-tried when
+#     it generates ConflictErrors.  This can be a problem when using
+#     a ZEO server and you have large numbers of simultaneous writes.
+#
+# Default: 3
+#
+# Example:
+#
+#    max-conflict-retries 10
 
 # Directive: warnfilter
 #



More information about the Zope-Checkins mailing list