[Checkins] SVN: relstorage/branches/1.1/ Use DROP TABLE IF EXISTS instead of TRUNCATE to clear 'temp_store' because:

Stefan H. Holek stefan at epy.co.at
Thu Jul 24 09:29:45 EDT 2008


Log message for revision 88789:
  Use DROP TABLE IF EXISTS instead of TRUNCATE to clear 'temp_store' because:
    - TRUNCATE has one page of caveats in the MySQL documentation.
    - TEMPORARY TABLEs have half a page of caveats when it comes to
      replication.
    - The end result is that 'temp_store' may not exist on the
      replication slave at the exact same time(s) it exists on the
      master.
  

Changed:
  U   relstorage/branches/1.1/CHANGES.txt
  U   relstorage/branches/1.1/relstorage/adapters/mysql.py

-=-
Modified: relstorage/branches/1.1/CHANGES.txt
===================================================================
--- relstorage/branches/1.1/CHANGES.txt	2008-07-24 12:47:10 UTC (rev 88788)
+++ relstorage/branches/1.1/CHANGES.txt	2008-07-24 13:29:44 UTC (rev 88789)
@@ -1,6 +1,15 @@
 
 RelStorage 1.1c1
 
+- Use DROP TABLE IF EXISTS instead of TRUNCATE to clear 'temp_store' because:
+
+  - TRUNCATE has one page of caveats in the MySQL documentation.
+  - TEMPORARY TABLEs have half a page of caveats when it comes to
+    replication.
+  - The end result is that 'temp_store' may not exist on the
+    replication slave at the exact same time(s) it exists on the
+    master.
+
 - Added optional memcache integration.  This is useful when the connection
   to the relational database has high latency.
 

Modified: relstorage/branches/1.1/relstorage/adapters/mysql.py
===================================================================
--- relstorage/branches/1.1/relstorage/adapters/mysql.py	2008-07-24 12:47:10 UTC (rev 88788)
+++ relstorage/branches/1.1/relstorage/adapters/mysql.py	2008-07-24 13:29:44 UTC (rev 88789)
@@ -398,11 +398,19 @@
             self.close(conn, cursor)
             raise
 
+    def _restart_temp_table(self, cursor):
+        """Restart the temporary table for storing objects"""
+        stmt = """
+        DROP TEMPORARY TABLE IF EXISTS temp_store
+        """
+        cursor.execute(stmt)
+        self._make_temp_table(cursor)
+
     def restart_store(self, cursor):
         """Reuse a store connection."""
         try:
             cursor.connection.rollback()
-            cursor.execute("TRUNCATE temp_store")
+            self._restart_temp_table(cursor)
         except (MySQLdb.OperationalError, MySQLdb.InterfaceError), e:
             raise StorageError(e)
 



More information about the Checkins mailing list