1515
1616import hlib .console
1717import hlib .error
18+ import hlib .locks
1819import hlib .log
1920from hlib .stats import stats as STATS
2021
@@ -30,7 +31,7 @@ def __init__(self, console, parser):
3031 self .parser .add_argument ('--enable-lt' , action = 'store_const' , dest = 'action' , const = 'enable-lt' )
3132 self .parser .add_argument ('--disable-lt' , action = 'store_const' , dest = 'action' , const = 'disable-lt' )
3233 self .parser .add_argument ('--pack' , action = 'store_const' , dest = 'action' , const = 'pack' )
33- self .parser .add_argument ('--minimize-cache ' , action = 'store_const' , dest = 'action' , const = 'minimize-cache ' )
34+ self .parser .add_argument ('--gc ' , action = 'store_const' , dest = 'action' , const = 'gc ' )
3435
3536 self .parser .add_argument ('--name' , action = 'store' , dest = 'name' )
3637
@@ -57,8 +58,8 @@ def handler(self, args):
5758 if args .action == 'pack' :
5859 return self .__get_db_by_name (args .name ).pack ()
5960
60- if args .action == 'minimize-cache ' :
61- return self .__get_db_by_name (args .name ).minimize_cache ()
61+ if args .action == 'gc ' :
62+ return self .__get_db_by_name (args .name ).globalGC ()
6263
6364 if args .action == 'update-stats' :
6465 return self .__get_db_by_name (args .name ).update_stats ()
@@ -134,8 +135,8 @@ def __init__(self, name, address, **kwargs):
134135 self .db = None
135136 self .root = None
136137
137- self .log_transaction_handler = self .__log_transaction
138- self .log_transaction_lock = threading . RLock ()
138+ self .log_transaction_handler = self .__nolog_transaction
139+ self .log_transaction_lock = hlib . locks . RLock (name = 'Transaction logging setup' )
139140
140141 self .kwargs = kwargs
141142
@@ -167,7 +168,7 @@ def on_request_finished(self, _):
167168 def is_opened (self ):
168169 return self .db != None
169170
170- def set_transaction_logging (self , enabled = True ):
171+ def set_transaction_logging (self , enabled = False ):
171172 with self .log_transaction_lock :
172173 if enabled :
173174 self .log_transaction_handler = self .__log_transaction
@@ -191,6 +192,9 @@ def connect(self):
191192 return (connection , self .root )
192193
193194 def log_transaction (self , * args , ** kwargs ):
195+ # Transaction logging is broken - because of locking - lock is required even for NOP action :(
196+ return
197+
194198 with self .log_transaction_lock :
195199 self .log_transaction_handler (* args , ** kwargs )
196200
@@ -259,6 +263,24 @@ def pack(self):
259263 def minimize_cache (self ):
260264 self .db .minimizeCache ()
261265
266+ def localGC (self ):
267+ hruntime .dbconn .cacheGC ()
268+ hruntime .dbconn .cacheMinimize ()
269+
270+ def poolGC (self ):
271+ self .db ._a ()
272+ self .db .pool .availableGC ()
273+ self .db .historical_pool .availableGC ()
274+ self .db ._r ()
275+
276+ def globalGC (self ):
277+ self .pack ()
278+
279+ self .db ._a ()
280+ self .db .pool .availableGC ()
281+ self .db .historical_pool .availableGC ()
282+ self .db ._r ()
283+
262284 def update_stats (self ):
263285 data = self .db .getActivityMonitor ().getActivityAnalysis (divisions = 1 )[0 ]
264286 connections = {}
@@ -271,18 +293,19 @@ def update_stats(self):
271293 'Info' : data ['info' ],
272294 'Before' : data ['before' ]
273295 }
296+ i += 1
274297
275298 for data in self .db .cacheDetailSize ():
276299 caches [data ['connection' ]] = {
300+ 'Connection' : data ['connection' ],
277301 'Non-ghost size' : data ['ngsize' ],
278302 'Size' : data ['size' ]
279303 }
280304
281- with STATS :
282- STATS .set (self .stats_name , 'Load' , data ['loads' ] if 'loads' in data else 0 )
283- STATS .set (self .stats_name , 'Stores' , data ['stores' ] if 'stores' in data else 0 )
284- STATS .set (self .stats_name , 'Connections' , connections )
285- STATS .set (self .stats_name , 'Caches' , caches )
305+ STATS .set (self .stats_name , 'Load' , data ['loads' ] if 'loads' in data else 0 )
306+ STATS .set (self .stats_name , 'Stores' , data ['stores' ] if 'stores' in data else 0 )
307+ STATS .set (self .stats_name , 'Connections' , connections )
308+ STATS .set (self .stats_name , 'Caches' , caches )
286309
287310class DBObject (persistent .Persistent ):
288311 def __init__ (self , * args , ** kwargs ):
0 commit comments