Note that there are some explanatory texts on larger screens.

plurals
  1. POInfluence of forking on existing mysql-connection
    primarykey
    data
    text
    <p>I have a server which is/should be able to handle a lot of connections at the same time. Now sometimes I have an error: “Lost connection to MySQL server during query”. At the time I am fixing this with </p> <pre><code>def mysql_handling(string): global cursor tries=0 while True: if tries&lt;5: try: cursor.execute(string) if 'SELECT' not in string: db.commit() break except MySQLdb.Error, e: print("Error %d: %s" %(e.args[0], e.args[1])) cursor.close() time.sleep(0.1) cursor = get_cursor() #setting up a new mysql connection #mysql_error_tracking(string) tries+=1 else: sys.exit(1) </code></pre> <p>So now I am able to handle a lot of connections at the same time, but at the times that I have this error (Lost conn.) I want to know at which query this happens, and if there is somekind of pattern in this. So to track this, I also want to store this in the mysql-database with a script somewhat like this:</p> <pre><code>def mysql_error_tracking(string): #Clone/fork try: error_serv = os.fork() except: print "error_FORK failed!" if error_serv: print 'there is a MYSQL-ERROR, SAVE!!!' cursor.execute("SELECT count FROM query_errors WHERE string= "+"'"+str(string)+"'") data=cursor.fetchone() print data if data is None: cursor.execute("INSERT INTO query_errors (string) VALUES ("+"'"+str(string)+"')") db.commit() print 'insert in queries' else: cursor.execute("UPDATE query_errors SET count=count+1 WHERE string= "+"'"+str(string)+"'") db.commit() print 'count ploes 1' sys.exit(0) </code></pre> <p>This does work, but <strong>forking</strong> the connection seems to really pressurize the already existing mysql-connection, is it better to just not-fork instead? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload