Motion - Bug Report 2007x 06x 27x 163751
You are here: Foswiki>Motion Web>BugReports>BugReport2007x06x27x163751 (18 May 2008, AngelCarpintero)Edit Attach

BUG: motion won't reconnect to mysql server if it's disconnected

I've had problems with motion getting 'stuck' if the mysql server dies or gets restarted. My expectation is that motion would try to reconnect to it. What it does now is just fill the log with the following message:

Jun 27 09:24:12 surv motion: [2] Mysql query failed: Success

motion.conf:sql_query insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')

 describe security;
| Field      | Type      | Null | Key | Default           | Extra |
| camera     | int(11)   | YES  |     | NULL              |       |
| filename   | char(80)  | NO   | MUL |                   |       |
| frame      | int(11)   | YES  |     | NULL              |       |
| file_type  | int(11)   | YES  |     | NULL              |       |
| time_stamp | timestamp | NO   | MUL | CURRENT_TIMESTAMP |       |
| text_event | char(40)  | YES  |     | NULL              |       |
| thumbnail  | char(80)  | YES  |     | NULL              |       |


Motion version: 3.2.7
ffmpeg version: unknown, but working dandy finally. :/
Shared libraries: ffmpeg, mysql, postgresql
Server OS: linux, gentoo.

-- A3ricJohanson - 27 Jun 2007

Follow up

Please upgrade to , and try to reproduce the problem

also could be interesting :

What version of Mysql are you using ?

What client library is linked with motion ?

-- AngelCarpintero - 28 Jun 2007

Fix record

Added a patch for mysql 5.x against svn r195.

This patch uses MYSQL_OPT_RECONNECT flag for mysql connection and changed default value for mysql_host ( replacing Not defined by localhost ).

-- AngelCarpintero - 09 Jul 2007

Why default to localhost?

This means that anyone starting Motion without having setup their MySQL with the right tables and user name and password will have an error.

It is probably very few that ever use MySQL with Motion and it is the host being undefined that disable the use of the MySQL feature. You should not have to build Motion without it. If you install an RPM the MySQL support is compiled in the binary but still most will never use the feature.

So it should be disabled by default.

-- KennethLavrsen - 09 Jul 2007

Just checked the code. I was wrong. It is the mysql_db option being undefined that disables the feature so it is OK to have localhost as default for the host.

Go ahead a apply the patch.

-- KennethLavrsen - 09 Jul 2007

Done ! wink

-- AngelCarpintero - 09 Jul 2007

BugReportForm edit

TopicTitle motion won't reconnect to mysql server if it's disconnected
BugStatus Released
AssignedBugTo AngelCarpintero
SubmittedBy A3ricJohanson
Topic attachments
I Attachment Action Size Date Who Comment
mysql-5-reconnect.diffdiff mysql-5-reconnect.diff manage 1 K 09 Jul 2007 - 09:47 AngelCarpintero Added mysql reconnection for mysql 5.x
Topic revision: r6 - 18 May 2008, AngelCarpintero
Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.