[or-cvs] r19613: {torctl} Fix SQLAlchemy consistency error exception. Droping tables d (torctl/trunk/python/TorCtl)

mikeperry at seul.org mikeperry at seul.org
Tue Jun 2 08:31:27 UTC 2009


Author: mikeperry
Date: 2009-06-02 04:31:26 -0400 (Tue, 02 Jun 2009)
New Revision: 19613

Modified:
   torctl/trunk/python/TorCtl/SQLSupport.py
Log:

Fix SQLAlchemy consistency error exception. Droping tables
does not automatically trigger their relations to get
dropped..



Modified: torctl/trunk/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/SQLSupport.py	2009-06-02 08:30:25 UTC (rev 19612)
+++ torctl/trunk/python/TorCtl/SQLSupport.py	2009-06-02 08:31:26 UTC (rev 19613)
@@ -609,13 +609,17 @@
 #################### Model Support ################
 def reset_all():
   # Need to keep routers around.. 
-  #for r in Router.query.all():
-  #  r.bw_history = [] # XXX: Is this sufficient/correct/necessary?
-  #  r.circuits = []
-  #  r.streams = []
-  #  r.stats = None
-  #  tc_session.add(r)
+  for r in Router.query.all():
+    # This appears to be needed. the relation tables do not get dropped 
+    # automatically.
+    r.circuits = []
+    r.streams = []
+    r.detached_streams = []
+    r.bw_history = [] 
+    r.stats = None
+    tc_session.add(r)
 
+  tc_session.commit()
   tc_session.clear()
 
   BwHistory.table.drop() # Will drop subclasses
@@ -632,9 +636,9 @@
 
   tc_session.commit()
 
-  for r in Router.query.all():
-    if len(r.bw_history) or len(r.circuits) or len(r.streams) or r.stats:
-      plog("WARN", "Router still has dropped data!")
+  #for r in Router.query.all():
+  #  if len(r.bw_history) or len(r.circuits) or len(r.streams) or r.stats:
+  #    plog("WARN", "Router still has dropped data!")
 
   plog("NOTICE", "Reset all SQL stats")
 



More information about the tor-commits mailing list