open-webui / helm-charts

72 stars 47 forks source link

Persistence configuration #98

Closed dcieslak19973 closed 2 weeks ago

dcieslak19973 commented 1 month ago

I'm trying to deploy OpenWebUI via the Helm Chart with persistence enabled. However, when I do so, the pod won't start, reporting:

File "/usr/local/lib/python3.11/site-packages/peewee.py", line 3322, in execute_sql
cursor.execute(sql, params or ())
sqlite3.OperationalError: database is locked

Here is the configuration for persistence in my values.yaml

    persistence:
      enabled: true
      storageClass: azurefile
      accessMode: ReadWriteMany
      size: 2Gi

I do not have any mounts specified

Thanks!

0xThresh commented 3 weeks ago

Hi @dcieslak19973, do you have more than one pod trying to read from the DB? I noticed you're using ReadWriteMany which I've never personally tested. Also, do you run into the same issue if you set accessMode: ReadWriteOnce?

dcieslak19973 commented 3 weeks ago

Currently, I only have 1 pod running. I chose ReadWriteMany to future-proof a state where I need to run multiple pods. I'll try setting it to ReadWriteOnce and report back positive/negative results when I have them

dcieslak19973 commented 3 weeks ago

It also fails (same message about the database lock) with a RWO volume claim

0xThresh commented 2 weeks ago

@dcieslak19973 I haven't been able to replicate this, but I also haven't used the azurefile storage class before. I was able to find a similar issue here, perhaps you could see if any of the solutions outlined here help you solve it: https://github.com/kubernetes/kubernetes/issues/59755

My next recommendation would be to use an external database (like a separate Postgres instance) to host your database instead to hopefully work around this issue. Let me know what you end up doing, thanks!

sir3mat commented 2 weeks ago

How to modify the PVC mount path for the Pipelines server?

Currently, when persistence.enabled is set to true, the PVC (Persistent Volume Claim) is mounted at /app/backend/data. However, should it be mounted at /app/pipelines instead? Which path is correct?

dcieslak19973 commented 2 weeks ago

@0xThresh - I will see if that potential workaround for AzureFiles is an option.

As far as using an external database, the documentation seems a bit thin or unclear in this regard. Is simply configuring DATABASE_URL ( https://docs.openwebui.com/getting-started/advanced-topics/env-configuration#database_url ) sufficient?

0xThresh commented 2 weeks ago

Yes, you'd set your database connection string in that variable and Open WebUI will connect to that DB instead. Note that it will not automatically migrate existing data though, so you'll either have to copy your data over, or just start with a fresh install that uses the external DB.

dcieslak19973 commented 2 weeks ago

Thanks @0xThresh . I've gone the Postgres route for now and can confirm chat history persists across pod restarts. In our dev environment, I don't have OIDC auth enabled, and saw that user accounts persisted to Postgres. In our Prod env, we are using OIDC for auth, so presumably the user accounts table in postgres will be empty?

0xThresh commented 2 weeks ago

I would assume that table would still map some info to the SSO user, such as their chat IDs, but I'm not intimately familiar with the DB schema. I asked others in Discord and will report back once I hear more.

Since the issue seemed external to Open WebUI/ the Helm chart and more specific to the AzureFile storage class, I'm going to close this out now. Thanks for reporting your issue, please feel free to open another issue if you see other weird behavior in the future!

0xThresh commented 2 weeks ago

@dcieslak19973 that DB should have users with an oauth_sub column mapped to their federated ID. Another contributor sent this as an example: image

ryadavso commented 6 days ago

i am using external postgres to persist data but it does not seam to persist files uploaded to knowledge base but facing similar issue with AzureFile storage

what are the other option we have to persist files uploaded by users