Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Slow startup times #4610

Open
5 of 6 tasks
tit1 opened this issue Nov 25, 2024 · 2 comments
Open
5 of 6 tasks

[BUG] - Slow startup times #4610

tit1 opened this issue Nov 25, 2024 · 2 comments
Labels
bug: confirmed bug Something isn't working

Comments

@tit1
Copy link

tit1 commented Nov 25, 2024

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

When starting up the Mealie containers the startup time for the DB is very Slow.
I have over 15,000 recipes and each time I need to restart my docker stack the mealie server looks for and runs migrations:

Switching to dedicated user
User uid: 1000
User gid: 1000

INFO 2024-11-25T09:10:15 - Started server process [1]
INFO 2024-11-25T09:10:15 - Waiting for application startup.
INFO 2024-11-25T09:10:15 - start: database initialization
INFO 2024-11-25T09:10:15 - Database connection established.
INFO 2024-11-25T09:10:15 - Context impl PostgresqlImpl.
INFO 2024-11-25T09:10:15 - Will assume transactional DDL.
INFO 2024-11-25T09:10:15 - Checking for migration data fixes
INFO 2024-11-25T09:15:18 - end: database initialization
INFO 2024-11-25T09:15:18 - -----SYSTEM STARTUP-----
INFO 2024-11-25T09:15:18 - ------APP SETTINGS------

As you can see the migration and data fixes takes a little over 5 minutes to complete.

I fully understand this during an upgrade as the system needs to check to ensure that the data is migrated correctly, but the majority of theses restarts are for editing env variables or a system reboot.

Steps to Reproduce

  1. load 15,000 recipes into Mealie
  2. shutdown the docker stack
  3. start the docker stack.

Please provide relevant logs

Switching to dedicated user
User uid: 1000
User gid: 1000

INFO 2024-11-25T09:10:15 - Started server process [1]
INFO 2024-11-25T09:10:15 - Waiting for application startup.
INFO 2024-11-25T09:10:15 - start: database initialization
INFO 2024-11-25T09:10:15 - Database connection established.
INFO 2024-11-25T09:10:15 - Context impl PostgresqlImpl.
INFO 2024-11-25T09:10:15 - Will assume transactional DDL.
INFO 2024-11-25T09:10:15 - Checking for migration data fixes
INFO 2024-11-25T09:15:18 - end: database initialization
INFO 2024-11-25T09:15:18 - -----SYSTEM STARTUP-----
INFO 2024-11-25T09:15:18 - ------APP SETTINGS------

Mealie Version

Mealie version: 2.2.0
DB type: PostgreSQL
Deployment type: Docker stack via Portainer
Volumes: Local directories - I am not using docker volumes.

Deployment

Docker (Linux)

Additional Deployment Details

No response

@tit1 tit1 added bug Something isn't working triage labels Nov 25, 2024
@hay-kot
Copy link
Collaborator

hay-kot commented Dec 4, 2024

Relevant code

def fix_migration_data(session: Session):
logger.info("Checking for migration data fixes")
fix_dangling_refs(session)
fix_recipe_normalized_search_properties(session)
fix_shopping_list_label_settings(session)
fix_group_slugs(session)
fix_normalized_unit_and_food_names(session)

@michael-genson - I'm not super familiar with all of these fixes. Do these need to run on every startup? Would it be possible to pin them to a specific migration? I'm assuming these only need to run if the database is pre-{some-version}

@michael-genson
Copy link
Collaborator

michael-genson commented Dec 4, 2024

I'm not 100% sure we caught all the root causes for some of these, but either way I'm in favor of pinning them to a particular migration. And then maybe always run them on backup restore just to be safe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants