Cannot create new events. Database errors.

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
CyanideSandwich
Posts: 4
Joined: Mon Sep 20, 2021 4:42 pm

Cannot create new events. Database errors.

Post by CyanideSandwich »

Hello. I am new to ZM and I have encountered an issue. I am sometimes getting the following error messages in my logs. When I do, new events aren't being created on the monitor(s) in question.

Sep 20 12:37:57 zm zmc_m4[32427]: ERR [zmc_m4] [Can't run query INSERT INTO `Frames` (`EventId`, `FrameId`, `Type`, `TimeStamp`, `Delta`, `Score`) VALUES #012( 189176, 29, 'Normal', from_unixtime( 1632155875 ), 4.60, 0 ),#012( 189176, 30, 'Normal', from_unixtime( 1632155875 ), 4.75, 0 ),#012( 189176, 31, 'Normal', from_unixtime( 1632155876 ), 4.95, 0 ),#012( 189176, 32, 'Normal', from_unixtime( 1632155876 ), 5.09, 0 ),#012( 189176, 33, 'Alarm', from_unixtime( 1632155876 ), 5.24, 2 ),#012( 189176, 34, 'Alarm', from_unixtime( 1632155876 ), 5.45, 3 ),#012( 189176, 35, 'Alarm', from_unixtime( 1632155876 ), 5.60, 6 ): Cannot add or update a child row: a foreign key constraint fails (`zm`.`Frames`, CONSTRAINT `Frames_ibfk_1` FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE)]
Sep 20 12:37:58 zm zmc_m1[32413]: INF [zmc_m1] [Front Porch: 321 - Gone into alarm state PreAlarmCount: 4 > AlarmFrameCount:5 Cause:Motion Right]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Can't run query INSERT INTO `Stats` (`EventId`, `FrameId`, `MonitorId`, `ZoneId`, `PixelDiff`, `AlarmPixels`, `FilterPixels`, `BlobPixels`,`Blobs`,`MinBlobSize`, `MaxBlobSize`, `MinX`, `MinY`, `MaxX`, `MaxY`,`Score`) VALUES #012(189176,29,4,8,28,2177,0,0,0,0,0,0,0,0,0,0),#012(189176,29,4,21,29,293,0,0,0,0,0,0,0,0,0,0),#012(189176,29,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,29,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,29,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,30,4,8,28,1724,0,0,0,0,0,0,0,0,0,0),#012(189176,30,4,21,35,347,0,0,0,0,0,0,0,0,0,0),#012(189176,30,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,30,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,30,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,31,4,8,26,1715,0,0,0,0,0,0,0,0,0,0),#012(189176,31,4,21,27,230,0,0,0,0,0,0,0,0,0,0),#012(189176,31,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,31,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,31,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,32,4,8,27,2316,0,0,0,0,0,0,0,0,0,0),#012(189176,32,4,21,32,335,0,0,0,0,0,0,0,0,0,0),#012(189176,32,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,32,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,32,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,33,4,8,29,2653,0,0,0,0,0,0,0,0,0,0),#012(189176,33,4,21,56,530,0,0,0,0,0,0,0,0,0,2),#012(189176,33,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,33,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,33,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,34,4,8,37,2858,0,0,0,0,0,0,0,0,0,0),#012(189176,34,4,21,69,939,0,0,0,0,0,0,0,0,0,3),#012(189176,34,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,34,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,34,4,13,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,35,4,8,38,3926,0,0,0,0,0,0,0,0,0,0),#012(189176,35,4,21,76,1640,0,0,0,0,0,0,0,0,0,6),#012(189176,35,4,10,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,35,4,11,0,0,0,0,0,0,0,0,0,0,0,0),#012(189176,35,4,13,0,0,0,0,0,0,0,0,0,0,0,0): Cannot add or update a child row: a foreign key constraint fails (`zm`.`Stats`, CONSTRAINT `Stats_ibfk_3` FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE)]
Sep 20 12:37:58 zm zmc_m2[32417]: INF [zmc_m2] [Back Porch: 350 - Gone into prealarm state]
Sep 20 12:37:58 zm zmc_m3[32422]: ERR [zmc_m3] [Can't open /zm/3/2021-09-20/189175/00054-capture.jpg for writing: No such file or directory]
Sep 20 12:37:58 zm zmc_m3[32422]: ERR [zmc_m3] [Failed to write frame image]
Sep 20 12:37:58 zm zmc_m3[32422]: ERR [zmc_m3] [Can't open /zm/3/2021-09-20/189175/00054-analyse.jpg for writing: No such file or directory]
Sep 20 12:37:58 zm zmc_m3[32422]: ERR [zmc_m3] [Failed to write analysis frame image]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Can't open /zm/4/2021-09-20/189176/00043-capture.jpg for writing: No such file or directory]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Failed to write frame image]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Can't open /zm/4/2021-09-20/189176/00043-analyse.jpg for writing: No such file or directory]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Failed to write analysis frame image]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Can't open /zm/4/2021-09-20/189176/00044-capture.jpg for writing: No such file or directory]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Failed to write frame image]
Sep 20 12:37:58 zm zmc_m4[32427]: ERR [zmc_m4] [Can't open /zm/4/2021-09-20/189176/00044-analyse.jpg for writing: No such file or directory]

For these errors, it seems like I can "fix" the problem by deleting the most recent event for the monitor. I have no idea if or what I am doing that would cause them to start happening.

Can somebody help me?
User avatar
iconnor
Posts: 2880
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Cannot create new events. Database errors.

Post by iconnor »

I've seen this when events were being deleted immediately after creation. Check your filters.

Any filter that deletes events or does much of anything should have an End Date/Time NOT NULL rule so that it only matches finished events.
CyanideSandwich
Posts: 4
Joined: Mon Sep 20, 2021 4:42 pm

Re: Cannot create new events. Database errors.

Post by CyanideSandwich »

Okay so I *thought* the only filters I had were the two that came with ZM. However I had a bunch of "_TMP" filters and a few of them were set to run in the background. I deleted all of these. So let's see what happens now.

Thanks!
EdwinZ
Posts: 1
Joined: Tue Jan 04, 2022 11:23 am

Re: Cannot create new events. Database errors.

Post by EdwinZ »

I had the same error, but no additional filters to PurgeWhenFull and Update DiskSpace, which puzzled me a lot.
Then I noticed that (due to another process logging extensively on the same partition) my Diskspace was at 80%, which triggered the PurgeWhenFull filter during an event, creating such parent/child database errors.
Cleaning up my partition solved the issue...
JCAK
Posts: 9
Joined: Mon Dec 20, 2021 2:56 am

Re: Cannot create new events. Database errors.

Post by JCAK »

iconnor wrote: Mon Sep 20, 2021 5:59 pm I've seen this when events were being deleted immediately after creation. Check your filters.

Any filter that deletes events or does much of anything should have an End Date/Time NOT NULL rule so that it only matches finished events.
I had the same problem and I could fix it following your suggest. THANKS !!
Post Reply