LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-23-2008, 11:27 PM   #1
nephish
Member
 
Registered: Jun 2005
Distribution: arch, ubuntu
Posts: 456

Rep: Reputation: 30
mysql with a problem table


i have a database that is the information station of our company. We monitor machines and send alerts to our customers or display their information on the web. The database is very busy, with some of our tables getting about 1.5 inserts per second. Sometimes more.

Our history table is growing about 45M / day

The process that puts data into the database and the processes that manipulate that data is run by threads in a python program. About 12 threads in all, each one either reading from or writing to a particular table. We have two tables that are causing us trouble, and another that will be soon.
Our history table because it is very very large, and another table we have that is small, like 140 rows, this is just where we put configuration variables that are read from the threads.

So, our large table and our small configuration are showing up a lot in the slow query log. I have read tons of online articles and i have an SQL book. Just can't seem to find what is breaking our system. We are getting errors like lock wait timeout, and msyql database has gone away.

The tables are all Innodb and the server has 8 dual-core processors, 16Gig of RAM, on a 32 bit version of Ubuntu Linux. ( our processors would not let us use a 64 bit )

What to i do about this small table ?

the server health meters in the mysql-admin are not ramping up. It is a problem that happens after a while of running, it will start crashing our engine with mysql errors, restarting the MySQL server does not seem to help, but rebooting the computer does help, but then after a few days we are in the same mess again.


thanks for any suggestions
 
Old 07-24-2008, 12:08 AM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Quote:
Originally Posted by nephish View Post
The process that puts data into the database and the processes that manipulate that data is run by threads in a python program. About 12 threads in all, each one either reading from or writing to a particular table. We have two tables that are causing us trouble, and another that will be soon.
Our history table because it is very very large, and another table we have that is small, like 140 rows, this is just where we put configuration variables that are read from the threads.
Python has a Global Interpreter Lock (GIL) that allows only one thread at a time to "run" within Python. It's likely that you're deadlocking like this:

Thread-1: Has GIL, waiting for lock to release on database
Thread-2: Waiting for GIL to release, has lock on database

That's the first thought that comes to mind for me...and once two threads get deadlocked like this, the Python program would come to a halt (until the lock timeout on the database allowed one Python Thread to bomb...but it wouldn't be too long before the condition arose again). To work around this, you could potentially run the 12 or so Python threads in their own process so if one locks, it won't cause a wait on the other 11.

As for the history table, can you run a weekly or monthly process to partition the table into, say, "History-2008-08", "History-2008-07", "History-2008-06", etc...? Breaking the large history table into smaller monthly history tables would greatly speed accesses and writes to the history table(s).
 
Old 07-24-2008, 12:19 AM   #3
nephish
Member
 
Registered: Jun 2005
Distribution: arch, ubuntu
Posts: 456

Original Poster
Rep: Reputation: 30
thanks, we have started the history split into different years, and it does make a difference. I had never know about the thread and python issue, will check out your workaround.

thanks again
 
  


Reply

Tags
mysql



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP/MYSQL problem. Rename of table-name solves the problem... mosedrengen Linux - Software 3 01-06-2006 07:07 AM
table views problem (MySQL ODBC OOo) landroni Linux - Software 0 08-19-2005 03:00 PM
Problem inserting data into a mysql table using PHP Rockgod2099 Programming 13 08-03-2005 12:27 AM
Problem with mysql table name mitrship Programming 2 07-25-2005 07:12 AM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration