Hello. I am having issue spinning up phoenix with docker postgres db. I keep getting the below error. ` ⚠️⚠️ Phoenix failed to migrate the database to the latest version. ⚠️⚠️ phoenix-1 | phoenix-1 | The database may be in a dirty state. To resolve this, the Alembic CLI can be used phoenix-1 | from the `src/phoenix/db` directory inside the Phoenix project root. From here, phoenix-1 | revert any partial migrations and run `alembic stamp` to reset the migration state, phoenix-1 | then try starting Phoenix again. ` Below is the docker compose file to reproduce the error. ```yaml # docker-compose.yml services: phoenix: image: arizephoenix/phoenix:latest # Must be greater than 4.0 version to work depends_on: - db ports: - 6006:6006 # PHOENIX_PORT - 4317:4317 # PHOENIX_GRPC_PORT - 9090:9090 # [Optional] PROMETHEUS PORT IF ENABLED environment: - PHOENIX_SQL_DATABASE_URL=postgresql://phoenix:postgres@db:5434/postgres db: image: postgres restart: always environment: - POSTGRES_USER=phoenix - POSTGRES_PASSWORD=postgres - POSTGRES_DB=postgres ports: - 5434 volumes: - database_data:/var/lib/postgresql/data volumes: database_data: driver: local
The error you're encountering suggests that the database migration process is failing, possibly due to a dirty state or version mismatch. This can occur if the database was initialized with a different version of PostgreSQL than the one currently being used. According to the Phoenix GitHub issue, one solution is to ensure that the PostgreSQL version is consistent. You can pin the PostgreSQL version in your Docker Compose file to avoid compatibility issues, as suggested in the Phoenix GitHub pull request.Try updating your Docker Compose file to specify a compatible PostgreSQL version, such as version 16, to prevent version-related errors: LBKSdb: image: postgres:16 restart: always environment: - POSTGRES_USER=phoenix - POSTGRES_PASSWORD=postgres - POSTGRES_DB=postgres ports: - 5434 volumes: - database_data:/var/lib/postgresql/dataLBKSWould you like more details on resolving migration issues?Sources:
- Phoenix GitHub issue
- Phoenix GitHub pull request
💡 Hint: Mention RunLLM in the thread for followups.
Hi Muhammad K. is there any chance you’ve installed a prerelease build of Phoenix in the past? The migration errors are worrying and it’s very unlikely you encounter them if you’re only updating Phoenix
No, I haven't. Although have been using phoenix before with SQLite but now I want to switch to Postgres and each time I try build the image with a postgres db it fails
Do you have any other pre-existing tables in your Postgres instance, or is it a fresh instance?
It's a fresh instance. From the compose file, I expect it spins up a fresh postgres instance.
it looks like it has a volume mount to disk.
can you try a fresh location on disk and see if the issue persists?
Hmmm, I think I saw that. Let me try what you said and revert
I have a question then. Does it mean I have to use a fresh postgres instance for phoenix. Is it possible I configure it to use an already existing postgres instance?
we definitely recommend using a fresh instance of postgres to avoid collision between previously existing tables and tables used by phoenix
Alright, thanks Xander S.
just as a bit of extra info, there is an environment variable called PHOENIX_SQL_DATABASE_SCHEMA, which is a string (say xyz) that if specified will create a new schema (which is kind of like a subfolder) of that same name (say xyz) in postgres and use that instead (so the queries will be select … from xyz.table etc).
Can I not create a new database on the same postgres instance which phoenix can not to. Since it's a fresh database I expect it to work. But when I tried that it didn't work, it gave the same error as the above. I am trying to avoid creating a new instance because my llm application already have a postgres instance running. What do you advice
