Error - Migrations in Graphql/Prefect -"Could not upgrade the database! Can’t locate revision identified by ‘x’"

Hello. I am using Prefect in a Linux Server.
When I start the prefect server, using “prefect server start”, I receive an error message from the graphql container saying “can’t locate revision identified by” and an id number.
This stops the graphql container and avoid prefect from running.
What could have been wrong?

1 Like

Are you just getting started with Prefect? If so, it would be better if you start with Prefect 2.0:

I must say that doesnt help.

I agree, but you didn’t give enough information to help more. Could you share more info? The following would be helpful:

  1. Where are you in your Prefect journey - are you just getting started or are you a long-time user who is already running and maintaining Prefect Server for a long time and is now only looking for help migrating to some new version
  2. If you are migrating, from which to which version are you migrating?
  3. Can you share the output of “prefect diagnostics”?
  4. Where does this run? What’s your infrastructure?
  5. Can you share a full exception traceback you are getting?

All I can say so far is that you face some issue with database migration (the error comes from alembic) and you may check the following resources:

https://discourse.prefect.io/tag/database-migrations

especially:

Hello Anna, you are right. I am running Prefect in a Linux server that is on premise. This structure is not new, but was not developed by me, I am replacing the creator of the system, and I entered not long ago in the team. So I am getting used to Prefect, I am not yet perfectly confortable with the system.

The traceback of the error:

postgres_1 | 2022-06-10 13:21:27.822 UTC [1] LOG: listening on IPv4 address “0.0.0.0”, port 5432
postgres_1 | 2022-06-10 13:21:27.822 UTC [1] LOG: listening on IPv6 address “::”, port 5432
postgres_1 | 2022-06-10 13:21:27.825 UTC [1] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
postgres_1 | 2022-06-10 13:21:27.851 UTC [26] LOG: database system was shut down at 2022-06-10 13:20:33 UTC
postgres_1 | 2022-06-10 13:21:27.872 UTC [1] LOG: database system is ready to accept connections
ui_1 | :space_invader::space_invader::space_invader: UI running at localhost:8080 :space_invader::space_invader::space_invader:
towel_1 | {“severity”: “INFO”, “name”: “prefect-server.Lazarus”, “message”: “Lazarus will start after an initial delay of 378 seconds…”}
towel_1 | {“severity”: “INFO”, “name”: “prefect-server.Scheduler”, “message”: “Scheduler will start after an initial delay of 176 seconds…”}
towel_1 | {“severity”: “INFO”, “name”: “prefect-server.ZombieKiller”, “message”: “ZombieKiller will start after an initial delay of 39 seconds…”}
graphql_1 |
graphql_1 | Running Alembic migrations…
graphql_1 | INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
graphql_1 | INFO [alembic.runtime.migration] Will assume transactional DDL.
graphql_1 |
graphql_1 | Could not upgrade the database!
graphql_1 | Error: Can’t locate revision identified by ‘3c87ad7e0b71’
graphql_1 |
graphql_1 | Running Alembic migrations…
graphql_1 | INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
graphql_1 | INFO [alembic.runtime.migration] Will assume transactional DDL.
graphql_1 |
graphql_1 | Could not upgrade the database!
graphql_1 | Error: Can’t locate revision identified by ‘3c87ad7e0b71’

I read the other answer that you pointed, it was helpful.
I ran “prefect-server database upgrade -y”.
But I am getting: “prefect-server: command not found”.

Afaik, this command is only available from the GraphQL container:

For Kubernetes:

kubectl exec graphqlPodName prefect-server database upgrade -y

If you run with docker-compose, the same command is:

docker exec graphql_1 prefect-server database upgrade -y

Then, after running DB migrations manually, you need to restart your Apollo container so that it can refetch the updated database schemas:

docker restart apollo_1

btw you still didn’t answer all questions - the above would be helpful

{
“config_overrides”: {},
“env_vars”: [
“PREFECT__SERVER__ENDPOINT”
],
“system_information”: {
“platform”: “Linux-5.4.0-113-generic-x86_64-with-glibc2.31”,
“prefect_backend”: “server”,
“prefect_version”: “0.13.12”,
“python_version”: “3.9.0”
}
}

Wow, this is a really old Prefect version (it looks like no upgrades have been made by your former colleague for over a year or two). Not sure whether an upgrade this way is possible since even syntax and many concepts since then have changed.

Is there any chance you can start a new Prefect Server version from scratch and reregister all flows to that new Server backend?

yup, almost 2 years without upgrades: 0.13.12 - Released on October 20, 2020.

Well, I could try… But I don’t know if it would be wise to do such a radical change, since I just started

What’s the reason you are upgrading in the first place?

if it works fine for you, you may stick to this version, but definitely worth upgrading

I will consider this idea!