frigate: Can't start docker container: disk I/O error

Describe the bug A clear and concise description of what your issue is.

 * Starting nginx nginx
   ...done.
Starting migrations
peewee_migrate                 INFO    : Starting migrations
peewee                         DEBUG   : ('CREATE TABLE IF NOT EXISTS "migratehistory" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "migrated_at" DATETIME NOT NULL)', [])
disk I/O error

** docker script **

docker run -d \
  --privileged \
  --name frigate \
  --restart=unless-stopped \
  --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
  -v $CONF/media:/media/frigate \
  -v $CONF/config:/config \
  -v /etc/localtime:/etc/localtime:ro \
  -e FRIGATE_RTSP_PASSWORD='password' \
  -p 5000:5000 \
  -p 1935:1935 \
  blakeblackshear/frigate:stable-amd64

Version of frigate Output from /api/version

blakeblackshear/frigate:stable-amd64

Config file Include your full config file wrapped in triple back ticks.

logger:
  default: debug
detectors:
  cpu1:
    type: cpu
  cpu2:
    type: cpu
mqtt:
  host: duboce
cameras:
  back:
    ffmpeg:
      inputs:
        - path: rtsp://viewer:{FRIGATE_RTSP_PASSWORD}@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - rtmp
    width: 1280
    height: 720
    fps: 5

Frigate container logs

Include relevant log output here

Frigate stats

Output from frigate's /api/stats endpoint

FFprobe from your camera

Run the following command and paste output below

ffprobe <stream_url>

Screenshots If applicable, add screenshots to help explain your problem.

Computer Hardware

  • OS: MacOs
  • Install method: Docker Command
  • Virtualization:Virtualbox
  • Coral Version: None
  • Network Setup: Wifi

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 19 (4 by maintainers)

Most upvoted comments

The folders are writable (as you can see) as there are some files in it.

I have ran into the same issue after I moved all Frigate data from the super-constrained storage of the VM where it runs, to my storage array thats accessible through a virtiofs mount.

It seems the problem is that sqlite does not like when you want to use a WAL-mode database through network, or such virtual filesystems: https://sqlite.org/forum/forumpost/6a0e396a2b8aa8e56001ddc1c618b90bee37465b7f47dc978f456b71d9525949 I havent found whats the reason for it, maybe its that virtiofs does not provide full support for file locking (1, 2), but thats not important.

Whats important is that such databases must stay local, meaning inside the VM/original system, and not be used through a network or virtiofs mount. As the above forum post suggests, Jellyfin docs also mention at the very beginning that the database file must stay local.

@blakeblackshear considering the traffic under this issue, would you please consider to mention this limitation of the database file somewhere here? It may be useful to have the database path override config option be mentioned too.

Finally, my solution was to keep the volume that stores /config stay in the VM. It does not take that much space anyway. Just dont forget when making backups that not everything is stored on your main storage array…

I am having the same issue when using a 9p virtio filesystem in a VM (underlying filesystem being shared is BTRFS). Directory is fully writable, and every file is 777 permissions (for testing) but still no. I’ve used frigate in the past on the same exact underlying filesystem and directory, with a bind mount to LXC container (using proxmox).

By creating a new directory on the 9p filesystem and using that one instead, frigate will work exactly once for a little bit longer with the below error, then after a reboot of the container or VM leads to the same error again.

  File "/usr/local/lib/python3.8/dist-packages/flask_sockets.py", line 40, in __call__
    handler, values = adapter.match()
  File "/usr/local/lib/python3.8/dist-packages/werkzeug/routing.py", line 1945, in match
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3065, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3404, in _connect
    self._add_conn_hooks(conn)
  File "/usr/local/lib/python3.8/dist-packages/playhouse/sqlite_ext.py", line 965, in _add_conn_hooks
    super(SqliteExtDatabase, self)._add_conn_hooks(conn)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3414, in _add_conn_hooks
    self._set_pragmas(conn)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3429, in _set_pragmas
    cursor.execute('PRAGMA %s = %s;' % (pragma, value))
sqlite3.OperationalError: disk I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/gevent/pywsgi.py", line 999, in handle_one_response
    self.run_application()
  File "/usr/local/lib/python3.8/dist-packages/geventwebsocket/handler.py", line 87, in run_application
    return super(WebSocketHandler, self).run_application()
  File "/usr/local/lib/python3.8/dist-packages/gevent/pywsgi.py", line 945, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask_sockets.py", line 48, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1948, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2242, in preprocess_request
    rv = func()
  File "/opt/frigate/frigate/http.py", line 89, in _db_connect
    database.connect()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3068, in connect
    self._initialize_connection(self._state.conn)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2902, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3065, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3404, in _connect
    self._add_conn_hooks(conn)
  File "/usr/local/lib/python3.8/dist-packages/playhouse/sqlite_ext.py", line 965, in _add_conn_hooks
    super(SqliteExtDatabase, self)._add_conn_hooks(conn)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3414, in _add_conn_hooks
    self._set_pragmas(conn)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3429, in _set_pragmas
    cursor.execute('PRAGMA %s = %s;' % (pragma, value))
peewee.OperationalError: disk I/O error
2021-07-09T01:57:58Z {'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '44802', 'HTTP_HOST': '192.168.1.28', (hidden keys: 28)} failed with OperationalError