Ticket #855: mysql-timeout-bcfg2-0-9-6.patch

File mysql-timeout-bcfg2-0-9-6.patch, 3.2 KB (added by somekool <[email protected]…>, 13 years ago)

VERY IMPORTANT

  • src/lib/Server/Reports/importscript.py

     
    1 #! /usr/bin/env python 
     1#!/usr/bin/env python 
    22'''Imports statistics.xml and clients.xml files in to database backend for new statistics engine''' 
    33__revision__ = '$Revision$' 
    44 
     
    5656def load_stats(cdata, sdata, vlevel, quick=False, location=''): 
    5757    cursor = connection.cursor() 
    5858    clients = {} 
    59     cursor.execute("SELECT name, id from reports_client;") 
    60     [clients.__setitem__(a, b) for a, b in cursor.fetchall()] 
    6159     
    6260    for node in sdata.findall('Node'): 
    6361        name = node.get('name') 
     62        cursor.execute("SELECT name, id from reports_client where name = '%s';" % (name) ) 
     63        [clients.__setitem__(a, b) for a, b in cursor.fetchall()] 
    6464        if not clients.has_key(name): 
    6565            cursor.execute(\ 
    6666                "INSERT INTO reports_client VALUES (NULL, %s, %s, NULL, NULL)", 
     
    167167                        cursor.execute("INSERT INTO reports_performance_interaction VALUES (NULL, %s, %s);", 
    168168                                       [item_id, current_interaction.id]) 
    169169                    except: 
     170                        # WTF 
    170171                        pass 
    171172 
    172     if vlevel > 1: 
    173         print("----------------INTERACTIONS SYNCED----------------") 
    174     cursor.execute("select reports_interaction.id, x.client_id from (select client_id, MAX(timestamp) as timer from reports_interaction Group BY client_id) x, reports_interaction where reports_interaction.client_id = x.client_id AND reports_interaction.timestamp = x.timer") 
    175     for row in cursor.fetchall(): 
    176         cursor.execute("UPDATE reports_client SET current_interaction_id = %s where reports_client.id = %s", 
    177                        [row[0],row[1]]) 
    178     if vlevel > 1: 
    179         print("------------LATEST INTERACTION SET----------------") 
    180  
    181173    for key in pingability.keys(): 
    182174        if key not in clients: 
    183175            #print "Ping Save Problem with client %s" % name 
  • src/lib/Component.py

     
    7171                    self.cleanup = False 
    7272                    return 
    7373            try: 
     74                # forcing django to reinitiate a new database connection for each fork() 
     75                from django.db import connection 
     76                connection.connection = None  
    7477                self.send_response(200) 
    7578                self.send_header("Content-type", "text/xml") 
    7679                self.send_header("Content-length", str(len(response))) 
     
    217220                if pid: 
    218221                    self.children.append(pid) 
    219222                    raise ForkedChild 
     223            # forcing django to reinitiate a new database connection for each fork() 
     224            from django.db import connection 
     225            connection.connection = None  
    220226            # all handlers must take address as the first argument 
    221227            response = self._dispatch(method, (address, ) + params) 
    222228            # wrap response in a singleton tuple