https://prefect.io logo
Title
e

Edmund Tian

12/21/2022, 3:03 PM
I’m getting a bunch of misc exceptions from Prefect during my Flow runs. Errors in thread (most of them are
sqlite3.OperationalError
). Anyone know what’s going on? Context: I’m using the
@flow
and
@task
decorators for my Python functions in my app hosted on Google Cloud Run. I’m not using Prefect Cloud. I’m on the following prefect version:
prefect==2.3.2
. It’s hard for me to repo because this occurs during my chron job. I haven’t been able to repo locally.
OperationalError:
(sqlite3.OperationalError) table flow_run has no column named state_name
[SQL: INSERT INTO flow_run (id, created, updated, name, state_type, state_name, run_count, expected_start_time, next_scheduled_start_time, start_time, end_time, total_run_time, work_queue_name, flow_version, parameters, idempotency_key, context, empirical_policy, tags, auto_scheduled, flow_id, deployment_id, infrastructure_document_id, parent_task_run_id, state_id) VALUES (:id, :created, :updated, :name, :state_type, :state_name, :run_count, :expected_start_time, :next_scheduled_start_time, :start_time, :end_time, :total_run_time, :work_queue_name, :flow_version, :parameters, :idempotency_key, :context, :empirical_policy, :tags, :auto_scheduled, :flow_id, :deployment_id, :infrastructure_document_id, :parent_task_run_id, :state_id)]
[parameters: {'id': 'ad0064ee-0c9d-4670-b3b0-2a6ce1e02663', 'created': '2022-12-21 10:16:19.981044', 'updated': '2022-12-21 10:16:19.992384', 'name': 'impressive-chicken', 'state_type': None, 'state_name': None, 'run_count': 0, 'expected_start_time': None, 'next_scheduled_start_time': None, 'start_time': None, 'end_time': None, 'total_run_time': '1970-01-01 00:00:00.000000', 'work_queue_name': None, 'flow_version': '8b1cbaa02c37a863a65da9d0bf8853fc', 'parameters': '{"user_id": "61ec6091-bf10-4960-9286-0313779c1efd", "start_date": 1671012979, "end_date": 1671617779, "run_id": null, "steps": null}', 'idempotency_key': None, 'context': '{}', 'empirical_policy': '{"max_retries": 0, "retry_delay_seconds": 0.0, "retries": 0, "retry_delay": 0}', 'tags': '[]', 'auto_scheduled': 0, 'flow_id': '5c408c31-f27f-4a84-9dbf-a003e8107675', 'deployment_id': None, 'infrastructure_document_id': None, 'parent_task_run_id': None, 'state_id': None}]
(Background on this error at: <https://sqlalche.me/e/14/e3q8>)
KeyError: 'script'
Stack trace:
File /usr/local/lib/python3.9/site-packages/prefect/orion/database/alembic_commands.py:29 in alembic_upgrade args locals
alembic.command.upgrade(alembic_config(), revision, sql=dry_run)
File /usr/local/lib/python3.9/site-packages/alembic/command.py:378 in upgrade args locals
script.run_env()
File /usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py:145 in __exit__ args locals
self._remove_proxy()
File /usr/local/lib/python3.9/site-packages/alembic/util/langhelpers.py:68 in _remove_proxy args locals
del globals_[attr_name]
KeyError: 'script'
OperationalError:
(sqlite3.OperationalError) table block_spec already exists
[SQL: 
CREATE TABLE block_spec (
	id CHAR(36) DEFAULT (
    (
        lower(hex(randomblob(4))) 
        || '-' 
        || lower(hex(randomblob(2))) 
        || '-4' 
        || substr(lower(hex(randomblob(2))),2) 
        || '-' 
        || substr('89ab',abs(random()) % 4 + 1, 1) 
        || substr(lower(hex(randomblob(2))),2) 
        || '-' 
        || lower(hex(randomblob(6)))
    )
    ) NOT NULL, 
	created DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f000', 'now')) NOT NULL, 
	updated DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f000', 'now')) NOT NULL, 
	name VARCHAR NOT NULL, 
	version VARCHAR NOT NULL, 
	type VARCHAR, 
	fields JSON DEFAULT '{}' NOT NULL, 
	CONSTRAINT pk_block_spec PRIMARY KEY (id)
)

]
(Background on this error at: <https://sqlalche.me/e/14/e3q8>)
TimeoutError
Stack trace:
File /app/pelm_utility_service/controllers/scraper_controller.py:68 in scrape_data args locals
flow_run(
Hide 4 non-project frames
File /usr/local/lib/python3.9/site-packages/prefect/flows.py:384 in __call__ args locals
return enter_flow_run_engine_from_flow_call(
File /usr/local/lib/python3.9/site-packages/prefect/engine.py:158 in enter_flow_run_engine_from_flow_call args locals
return anyio.run(begin_run)
File /usr/local/lib/python3.9/site-packages/anyio/_core/_eventloop.py:70 in run args locals
return asynclib.run(func, *args, **backend_options)
File /usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py:292 in run args locals
return native_run(wrapper(), debug=debug)
File /usr/local/lib/python3.9/asyncio/runners.py:44 in run args locals
return loop.run_until_complete(main)
File /usr/local/lib/python3.9/asyncio/base_events.py:647 in run_until_complete args locals
return future.result()
Hide 3 non-project frames
File /usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py:287 in wrapper locals
return await func(*args)
File /usr/local/lib/python3.9/site-packages/prefect/client.py:101 in with_injected_client args locals
async with client_context as client:
File /usr/local/lib/python3.9/site-packages/prefect/client.py:1905 in __aenter__ args locals
self._ephemeral_lifespan = await self._exit_stack.enter_async_context(
File /usr/local/lib/python3.9/contextlib.py:575 in enter_async_context args locals
result = await _cm_type.__aenter__(cm)
File /usr/local/lib/python3.9/contextlib.py:181 in __aenter__ args locals
return await self.gen.__anext__()
Hide 4 non-project frames
File /usr/local/lib/python3.9/site-packages/prefect/client.py:185 in app_lifespan_context args locals
await context.__aenter__()
File /usr/local/lib/python3.9/site-packages/asgi_lifespan/_manager.py:90 in __aenter__ args locals
await self.startup()
File /usr/local/lib/python3.9/site-packages/asgi_lifespan/_manager.py:31 in startup args locals
await self._concurrency_backend.run_and_fail_after(
File /usr/local/lib/python3.9/site-packages/asgi_lifespan/_concurrency/asyncio.py:46 in run_and_fail_after args locals
raise TimeoutError
b

Bianca Hoch

12/21/2022, 7:43 PM
Hello Edmund, could you try the following steps in this article to see if it helps? • When I try to start Orion, I get “sqlite3.OperationalError: table flow already exists” - how to troubleshoot this
e

Edmund Tian

01/10/2023, 9:49 PM
Hmm I don’t think that’s related since my app is deployed to GCP Cloud Run. All I did is add the
@flow
decorator to one of my functions. I have a daily job that makes a request to my Cloud Run App and runs my data job. A new container is created each day for this job, so I should be starting from a clean slate. @Anna Geller could you help me with this?
a

Anna Geller

01/11/2023, 4:51 PM
generally I don't know much about self-hosting, this post is for Cloud (which I highly recommend, it's free to use)