mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
7.52k stars 753 forks source link

Attempt to write only database #3177

Closed keinfilter closed 9 months ago

keinfilter commented 9 months ago

First Check

What is the issue you are experiencing?

If I try to add a new recipe or add an existing recipe to the meal planner, the error message is logged.

Steps to Reproduce

  1. Open mealie

  2. add a new recipe by add recipe manually

  3. error box "unknown error" is displayed

  4. open mealie meal planner

  5. select random or any specific meal to add to the planner

  6. error message "an unexpected error occured" ( Ein unerwarteter Fehler ist aufgetreten) pops up on top of the page

Please provide relevant logs

ERROR: 15-Feb-24 12:41:16 Unknown Error on recipe controller action ERROR: 15-Feb-24 12:41:16 (sqlite3.OperationalError) attempt to write a readonly database [SQL: INSERT INTO recipes (id, slug, group_id, user_id, name, description, image, total_time, prep_time, perform_time, cook_time, recipe_yield, "recipeCuisine", rating, org_url, is_ocr_recipe, date_added, date_updated, last_made, name_normalized, description_normalized, created_at, update_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('879a74b170db4a25a9280cf371e99c44', 'gebackener-lachs-mit-zitronen-knoblauch-sosse-und-ofengemuse', 'ecbadda22da7423ca40d57af0c998286', '60399cd312c646c9be489489269dc001', 'Gebackener Lachs mit Zitronen-Knoblauch-Soße und Ofengemüse', '', None, None, None, None, None, None, None, None, None, 0, '2024-02-15', '2024-02-15 12:41:16.254098', None, 'gebackener lachs mit zitronen-knoblauch-sosse und ofengemuse', '', '2024-02-15 12:41:16.256267', '2024-02-15 12:41:16.256268')] (Background on this error at: https://sqlalche.me/e/20/e3q8) Traceback (most recent call last): File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1965, in _exec_single_context self.dialect.do_execute( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 921, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: attempt to write a readonly database

The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/mealie/routes/recipe/recipe_crud_routes.py", line 294, in create_one new_recipe = self.service.create_one(data) File "/app/mealie/services/recipe/recipe_service.py", line 148, in create_one new_recipe = self.repos.recipes.create(data) File "/app/mealie/repos/repository_recipes.py", line 36, in create return super().create(document) File "/app/mealie/repos/repository_generic.py", line 171, in create self.session.commit() File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1920, in commit trans.commit(_to_root=True) File "", line 2, in commit File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go ret_value = fn(self, *arg, *kw) File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1236, in commit self._prepare_impl() File "", line 2, in _prepare_impl File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go ret_value = fn(self, arg, **kw) File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1211, in _prepare_impl self.session.flush() File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4163, in flush self._flush(objects) File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4298, in _flush with util.safe_reraise(): File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4259, in _flush flush_context.execute() File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute rec.execute(self) (Background on this error at: https://sqlalche.me/e/20/e3q8)`

Mealie Version

1.2.0

Deployment

Docker (Linux)

Additional Deployment Details

I installed alpine linux in a docker container hosted on proxmox. The default SQLite docker-compose.yaml has been added via Portainer. The volume media/mealie-data is an external hard-drive mounted to docker. I gave already full "rwx" permissions to the user, group and others.

`--- version: "3.7" services: mealie: image: ghcr.io/mealie-recipes/mealie:v1.2.0 container_name: mealie ports:

volumes: mealie-data: driver: local`

boc-the-git commented 9 months ago

There is a known issue with using SQLite and network storage - it's flagged on the installation page.. I wonder if you're running into a similar issue 🤔

boc-the-git commented 9 months ago

Note you'll be after 3 backticks for multi-line code formatting, which is why your single backticks haven't worked.

keinfilter commented 9 months ago

Thank you for your quick response.

The external hard drive is connected via USB 3.0 port to the PC. The mealie folder is provided to the docker container by Proxmox Mount Point to the Alpine host system. From my understanding, the docker container does not know, if the volume is a NAS or local device. Is there any chance to find out, if the database has somehow been locked?

boc-the-git commented 9 months ago

I don't have any knowledge around that I'm afraid.

For the purposes of debugging I'd suggest you spin up a new container that isn't trying to stick the DB on an external drive, and see how that goes. (sticking it in a named volume, as the example files does, would be a good test)

keinfilter commented 9 months ago

Thank you again for your suggestion. I will run the default setup as described on the installation page. If this goes well, do you have any best practice, how I put my database on an external hard drive? I would like to stick with SQLite. What are the next steps to reach my goal? Thanks for your help again!

boc-the-git commented 9 months ago

I'm afraid I have no advice to give, as I don't know what the underlying issue actually is.

My initial advice would be to think about your use case and whether it actually matters. What benefit do you get having it on an external hard drive vs on the main drive? Let it live in the named volume and perform backups to the external drive perhaps (and other locations, look up the 3-2-1 strategy if unaware).

keinfilter commented 9 months ago

My internal hard drive is too small for all the data, also of other containers. As a result, I always separate system data and application specific data. In most cases, this eases the restore procedure.

Ok, so I will setup a new container trying the Postgres database. Thanks again for your help!