[Checkins] SVN: relstorage/trunk/ Log the new replica when switching

Shane Hathaway shane at hathawaymix.org
Fri Sep 30 14:46:42 EST 2011


Log message for revision 123002:
  Log the new replica when switching
  

Changed:
  U   relstorage/trunk/CHANGES.txt
  U   relstorage/trunk/relstorage/adapters/mysql.py
  U   relstorage/trunk/relstorage/adapters/oracle.py
  U   relstorage/trunk/relstorage/adapters/postgresql.py

-=-
Modified: relstorage/trunk/CHANGES.txt
===================================================================
--- relstorage/trunk/CHANGES.txt	2011-09-30 18:19:45 UTC (rev 123001)
+++ relstorage/trunk/CHANGES.txt	2011-09-30 19:46:42 UTC (rev 123002)
@@ -20,10 +20,13 @@
   the database gets up to date. A subsequent transaction will no longer
   be stale.
 
-- Added the revert-when-stale option, which can disable the new
-  behavior for stale database connections.  This option is intended
-  for highly available, read-only ZODB clients.  It would
-  confuse users of read-write ZODB clients.
+- Added the revert-when-stale option. When the option is true and the
+  database connection is stale, RelStorage reverts the ZODB connection
+  to the stale state rather than raise ReadConflictError. This is the
+  old behavior. This option is intended for highly available, read-only
+  ZODB clients. This option would probably confuse users of read-write
+  ZODB clients, whose changes would seem to be temporarily reverted
+  sometimes.
 
 TODO: provide a default random memcache prefix that is consistent per database.
 

Modified: relstorage/trunk/relstorage/adapters/mysql.py
===================================================================
--- relstorage/trunk/relstorage/adapters/mysql.py	2011-09-30 18:19:45 UTC (rev 123001)
+++ relstorage/trunk/relstorage/adapters/mysql.py	2011-09-30 19:46:42 UTC (rev 123002)
@@ -232,15 +232,14 @@
                 return conn, cursor
             except MySQLdb.OperationalError, e:
                 if replica is not None:
-                    log.warning("Unable to connect to replica %s: %s",
-                        replica, e)
-                    replica = replica_selector.next()
-                    if replica is not None:
-                        # try the next replica
+                    next_replica = replica_selector.next()
+                    if next_replica is not None:
+                        log.warning("Unable to connect to replica %s: %s, "
+                            "now trying %s", replica, e, next_replica)
+                        replica = next_replica
                         params = self._alter_params(replica)
                         continue
-                else:
-                    log.warning("Unable to connect: %s", e)
+                log.warning("Unable to connect: %s", e)
                 raise
 
     def open_for_load(self):

Modified: relstorage/trunk/relstorage/adapters/oracle.py
===================================================================
--- relstorage/trunk/relstorage/adapters/oracle.py	2011-09-30 18:19:45 UTC (rev 123001)
+++ relstorage/trunk/relstorage/adapters/oracle.py	2011-09-30 19:46:42 UTC (rev 123002)
@@ -305,13 +305,14 @@
                 return conn, cursor
 
             except cx_Oracle.OperationalError, e:
-                log.warning("Unable to connect to DSN %s: %s", dsn, e)
                 if replica_selector is not None:
-                    replica = replica_selector.next()
-                    if replica is not None:
-                        # try the new replica
-                        dsn = replica
+                    next_dsn = replica_selector.next()
+                    if next_dsn is not None:
+                        log.warning("Unable to connect to DSN %s: %s, "
+                            "now trying %s", dsn, e, next_dsn)
+                        dsn = next_dsn
                         continue
+                log.warning("Unable to connect: %s", e)
                 raise
 
     def open_for_load(self):

Modified: relstorage/trunk/relstorage/adapters/postgresql.py
===================================================================
--- relstorage/trunk/relstorage/adapters/postgresql.py	2011-09-30 18:19:45 UTC (rev 123001)
+++ relstorage/trunk/relstorage/adapters/postgresql.py	2011-09-30 19:46:42 UTC (rev 123002)
@@ -198,15 +198,14 @@
                 return conn, cursor
             except psycopg2.OperationalError, e:
                 if replica is not None:
-                    log.warning("Unable to connect to replica %s: %s",
-                        replica, e)
-                    replica = replica_selector.next()
-                    if replica is not None:
-                        # try the new replica
+                    next_replica = replica_selector.next()
+                    if next_replica is not None:
+                        log.warning("Unable to connect to replica %s: %s, "
+                            "now trying %s", replica, e, next_replica)
+                        replica = next_replica
                         dsn = self._alter_dsn(replica)
                         continue
-                else:
-                    log.warning("Unable to connect: %s", e)
+                log.warning("Unable to connect: %s", e)
                 raise
 
     def open_for_load(self):



More information about the checkins mailing list