Opened 16 years ago
Closed 16 years ago
#5482 closed patch (fixed)
PATCH: Purge unused database-connections after 3600 secs [SVN: Trunk]
Reported by: | Owned by: | danielk | |
---|---|---|---|
Priority: | minor | Milestone: | 0.22 |
Component: | mythtv | Version: | head |
Severity: | medium | Keywords: | |
Cc: | Ticket locked: | no |
Description
Mysql has this variable max_connect_errors which is used to protect the db from possible attackers. If connect errors increase over time to the max_connect_errors the Mysql db will block the host from connecting for ever.
The attached patch purges unsused db-connections after they have been idle more than 1 hour in the hope that mysql will not count those connections into max_connect_errors counter if they would be allowed be terminated by MySQL instead.
Mythtv will create additional threads in case there are more incoming processing requests than available threads. The created threads will go into pool later on. However, there might be days and days until the next busy period where the same amount of db-connections are really required.
The attached patch also rotates the db-connections in the pool instead of always preferring on using the same threads.
Attachments (3)
Change History (6)
Changed 16 years ago by
Attachment: | purge_connections.patch added |
---|
comment:1 Changed 16 years ago by
In addition to the previous patch, the following change should be applied:
diff -u -b -w mythdbcon.cpp mythdbcon.cpp.mod --- mythdbcon.cpp 2008-06-28 11:15:53.000000000 +0300 +++ mythdbcon.cpp.mod 2008-06-28 11:15:43.000000000 +0300 @@ -33,8 +33,8 @@
m_db = QSqlDatabase(); forces a destroy and must be done before
removeDatabase() so that connections and queries are cleaned up correctly
- QSqlDatabase::removeDatabase(m_name);
}
+ QSqlDatabase::removeDatabase(m_name);
}
bool MSqlDatabase::isOpen()
As the QSqlDatabase::addDatabase() call is done in constructor regardles if the db-connection is openede or not, also the call to QSqlDatabase::removeDatabase should be done always when destroying the object. Currently, if the db-connection is for some reason never openeded, we possibly leak resources (or QSqlDatabase leaks resources).
Changed 16 years ago by
Attachment: | remove_db.patch added |
---|
Always call the QSqlDatabase::removeDatabase() as we call addDatabase() in constructor and not in openDatabase() or such.
comment:2 Changed 16 years ago by
Milestone: | unknown → 0.22 |
---|---|
Owner: | changed from Isaac Richards to danielk |
Status: | new → assigned |
Changed 16 years ago by
Attachment: | purge_connections-v2.patch added |
---|
Fixed version: Purge un-used db-connections after 3600s of idle time
comment:3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [17834]) Fixes #5482. Avoids having DB connections go stale using with two simple modificatinos to mythdbcon.
1st we rotate our DB connections. 2nd we expire connections that have gone unused for 1-2 hours.
Patch from tomino, modified slightly by me.
Unfortunately the binary revision must be updated, so plugins must be recompiled.
Purge un-used db-connections after 3600s of idle time