So I characterized the issue a bit more using SMTP notifications, but I suspect this extends to any blocked notification. When a notification is blocked, AD waits (2 min on my factory Pi image) before timing out and moving on to the next notification. However, during this time, other zone events aren't being logged. When the SMTP blocking ends, other events are processed, but they're given the timestamp of the time the logger gets to them, not when they occurred.
To demonstrate:
I blocked SMTP with an iptables rule and then opened/closed a door (ENTRY Laundry & Side Doors) that sends a SMTP notification for both events. I then walked around triggering other events. No events showed up in the log until door open + 2min at which point the door open event showed up with a 2 min delayed timestamp. At this point I presume AD moves to the next event, the door close, and tries to send its SMTP notification. The log was again silent for 2 more min at which point the door close showed up. AD then moves on to the next event(s) and they all show up with effectively the same timestamp as the door close timestamp. The MOTION Kitchen zone was the last zone triggered just before the first door open notification would be attempted.
AD Events Log:
- Code: Select all
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:44 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:44 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:44 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:44 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:44 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:44 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:43 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:43 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:43 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:43 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:43 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:43 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:43 AM ZONE RESTORE Zone ENTRY Rear Sliding Doors (3) has been restored.
2018-3-20 9:00:43 AM ZONE FAULT Zone ENTRY Rear Sliding Doors (3) has been faulted.
2018-3-20 9:00:42 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:42 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:42 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:42 AM ZONE FAULT Zone DOOR Basement, MOTION Fmly-Foyer (5) has been faulted.
2018-3-20 9:00:42 AM ZONE RESTORE Zone MOTION Kitchen (47) has been restored.
2018-3-20 9:00:42 AM ZONE RESTORE Zone DOOR Basement, MOTION Fmly-Foyer (5) has been restored.
2018-3-20 9:00:42 AM ZONE RESTORE Zone ENTRY Laundry & Side Doors (2) has been restored.
2018-3-20 8:58:29 AM ZONE FAULT Zone ENTRY Laundry & Side Doors (2) has been faulted.
2018-3-20 8:56:07 AM ZONE FAULT Zone MOTION Kitchen (47) has been faulted.
So while the main AD thread is clearly recording events, the "blocking" problem is that logging and notification seem to be in the same thread, so blocking in the notification also blocks logging in the thread, resulting in incorrect timestamps on the zone events. Things come out in the correct order, just with the wrong time. The wrong time would presumably appear in the notification timestamps of other notification vectors that aren't blocked too. If you're doing a lot of notifications that are blocked, and there are a lot of events, the timestamps become meaningless until events that happen subsequent to when the blocked notifications clear. So, that's the problem I'll look at. If logging can be done before sending notifications off to a thread, or an accurate timestamp recorded and propagated through the logging and notification thread, that should solve the problem. A second thing to look at will be threading out each notification separately, so unblocked notification vectors aren't held sending up by blocked vectors.