Frigate and HAOS Network Storage Issues

Hi all,

Ive just jumped back into HAOS, I used Home Assistant back in the early days and dropped it as it was to difficult to use at the time, it seems to be a more polished solution these days so Im having another go at it and trying to move away from Homekit.

I have Frigate setup and working fine, but I’m seeing major issues when using the intergrated network sharing.

I have everything done correctly, and Frigate is recording to /media/frigate just fine…until the network share is interupted, frigate keeps recording to the /media/frigate, but now its recording to local storage, and once that happens, the mount point is unable to be used by HAOS again.

To fix this, I have to shut down Frigate, use a terminal add on, delete the frigate folder from media, then go back to storage in HAOS settings, and reconnect the network share, then I need to delete the frigate.db folder and start frigate back up, where it now works correctly and is recording to the network share again.

But after doing all this, I have now lost all the logged clips in Frigate, they are still availble on the network share, but Frigate cant see them as it has generated a new database, and more to this, if I dont delete the old database, it just throws errors and still thinks its recording to local storage and nothing works as it should.

To be honest, I do manual SMB shares in linux all the time, and I have never seen this kind of behavior, once a folder is mounted as a SMB share via fstab, it stays that way, regarless if the share is online or not, you cant creat a local folder in the same location with the same name, not until you unmount and delete it.

Also I tried mapping the frigate.db file to the share location, but Frigate will not startup, this is only happing in HAOS, if I run frigate in a docker container, or on TruNAS Scale, it will let me save the frigate.db to the SMB share.

This behavior is odd, and is a real deal breaker, once all this happens, Frigate cant manage the clips anymore so you will have to go in and delete them from the NAS manually.

I see this as more of a HAOS issue rather than a Frigate issue, maybe its some of both? Frigate should allow me to put the database file on the share, I would rather Frigate just crash or stop if it loses the network share, and HAOS shore lock the mount point end of story, no matter if the network is up or down, as this can happen anytime, and it will happen at some point, and when it does, you lose access to all your motion detection clips from the web interface.

1 Like

I’ve read somewhere that there’s an issue with HAOS 11.3 and SMB that should be solved with the next update.

I’ve had a similar issue with a different integration. Reverting to HAOS 11.3.rc1 did the trick for me, but I was told the better way would be to wait for 11.4.

I already tried 11.3 and rolled back to 11.2, there is additional issues with the latest release which causes SMB to drop periodically, the issue I have is the way HAOS handles SMB mounting period, hopefully the they have a better solution in 11.4.

They need to lock that mount point at system startup, regardless of the network status.

Also the Frigate dev needs to allow the database to be kept on the SMB storage in HAOS, this would make recovery easier, one could then just shut it down, recover the smb share, then start Frigate back up and it picks up the shared database file again, the way it currently works, you will lose your database everytime there is a network interuption.

I think the underlying issue is not with HA. However, it was found and confirmed.

I’m reasonably sure 11.4 will cover all bases.

11.3.rc1 (not 11.3!) works for me. Otherwise, patience is key.

that is not accurate, frigate recommends storing the DB in /config for numerous reasons. The main one being that sqlite does not work well on network storage and that causes users many problems. In any case network interruptions will not cause the database to be lost in any way if frigate is setup the way that the docs recommend for HA network storage

What is not accurate?? Im not refering to losing your video clips, I refering to the cataloging of them.

What I said is absolutely true, once the SMB share drops, you will have to shutdown frigate, reconnect the share, then delete the database file, if you dont, it will be looking for the last files it saved, which were to the local drive, but they are not there anymore as you have to remove that folder so HAOS can create the mount point again, this whole thing had me chasing my own tail, I can now similuate this issue and its 100% repeatable, I suppose a work a round would me to rename /media/frigate to something else, then copy those files back once frigate is up again, then at least the files its looking for will be there.

I would prefer that Frigate just exit/kill itself if the share drops, that way once the share is up again, you can restart frigate and there is no loss of the database.

If the database was kept in the same location as the video files, it would be far better, just keep that database file with the files its related to, I dont know why it cant, it should, and the docker setup I tested, I could do that, I had no issues, the database was in the mounted smb share, and work perfectly, I did this in Proxmox with a Debian basic image and Docker.

There is no reason to delete the database file. We handle the scenario where a recording file is in the DB but not in the storage.

Except frigate doesn’t know, frigate is handed storage at /media/frigate and that is all it knows. The supervisor could do this if the feature was available, many users do this via docker already.

Many user has extensive problems with the DB failing while running on network storage. With that said the DB location has been configurable for many versions so if you want to change the location you can do that.

If I copy the local files that are genrated over to the smb share once I bring it back up, then everything does appear to work, but if I dont and and I delete them instead, I end up with errors in the log.

I just installed 11.4 and this appears to be working more reliably, so hopefully this is a non issue moving forwards.

In regards to storing the database file on the share, this doesnt appear to work in HAOS for some reason, I have tried, Frigate doesnt seem to like it, I need to point it to the config location as described in the documentation.

I think the main issue is HAOS releasing the mount point when the smb share drops and allowing anything to be written to that location, instead it should lock the location so no data can be saved there until the share is back up, this would prevent all of the issues Ive been having.

yes, and that is not a big deal, certainly not a reason to delete the DB file.

yes, this is already something that docker itself supports

I have been having this exact same issue, maybe we could get an option for Home Assistant to manage the share such that the apps continue to work, and when the network connection is restored it will migrate the files to it.

Does anybody have a good mechanism for detecting when it has lost the network share?

It seems once it gets into this state I need to do a turn it off/on again, might be a VM issue. (Running Home Assistant in VM on Unraid with Frigrate using network mount)

I was able to get a notification setup using System Monitor Integration

By enabling:
system_monitor_disk_free

At least now I can know before I get the X Gig remaining.

With the latest updates, the issue is mostly fixed, looks like the devs have hardened the SMB/CIFS setup and Frigate wont start now unless HA has the share up, also you can check on the shares now and you can see if they are online with out having to re-enter your SMB credetials.

i installed frigate with HAOS VM on Proxmox and a Samba server with LXC on the same proxmox and i got ongoing these mounted media/storage problem , not always but randomly when power was off and it doesnT matter what i have changed ,e.g. delay the start of frigate and so on… finally guess what,i put my frigate media share on a standalone standard windows computer and it is running, it doesnt matter how often i switch off and on proxmox or homeassistant VM, it is always mounting correclty the media/share always… maybe it is a problem of proxmox network bridge that the VM can not access fast enough the samba LXC, i do not know,maybe installed samba LXC on a standalone computer will solve the problem too…