Skip to content

Tifeatures exits with asyncpg.exceptions.UndefinedTableError #49

@rodrigoalmeida94

Description

@rodrigoalmeida94

When connecting to an empty database (i.e. no tables) tifeatures returns the following exception:

2022-08-04 14:15:44.133 CEST
using new connection
2022-08-04 14:15:44.500 CEST
ERROR: Traceback (most recent call last):
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 635, in lifespan
2022-08-04 14:15:44.500 CEST
 async with self.lifespan_context(app):
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 530, in __aenter__
2022-08-04 14:15:44.500 CEST
 await self._router.startup()
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 612, in startup
2022-08-04 14:15:44.500 CEST
 await handler()
2022-08-04 14:15:44.500 CEST
 File "/app/./cerulean_cloud/cloud_run_tifeatures/handler.py", line 108, in startup_event
2022-08-04 14:15:44.500 CEST
 await register_table_catalog(app)
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/tifeatures/db.py", line 51, in register_table_catalog
2022-08-04 14:15:44.500 CEST
 app.state.table_catalog = await get_table_index(app.state.pool)
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/tifeatures/dbmodel.py", line 246, in get_table_index
2022-08-04 14:15:44.500 CEST
 rows = await conn.fetch_b(
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/buildpg/asyncpg.py", line 64, in fetch_b
2022-08-04 14:15:44.500 CEST
 return await self.fetch(query, *args, timeout=_timeout)
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 621, in fetch
2022-08-04 14:15:44.500 CEST
 return await self._execute(
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 1659, in _execute
2022-08-04 14:15:44.500 CEST
 result, _ = await self.__execute(
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 1684, in __execute
2022-08-04 14:15:44.500 CEST
 return await self._do_execute(
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 1711, in _do_execute

2022-08-04 14:15:44.500 CEST
 stmt = await self._get_statement(
2022-08-04 14:15:44.500 CEST
 File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 398, in _get_statement
2022-08-04 14:15:44.500 CEST
 statement = await self._protocol.prepare(
2022-08-04 14:15:44.500 CEST
 File "asyncpg/protocol/protocol.pyx", line 168, in prepare
2022-08-04 14:15:44.500 CEST
asyncpg.exceptions.UndefinedTableError: relation "geometry_columns" does not exist
2022-08-04 14:15:44.500 CEST
2022-08-04 14:15:44.500 CEST
ERROR: Application startup failed. Exiting.
2022-08-04 14:15:44.715 CEST
Container called exit(3).

In a lot of deployment cases, the DB is deployed and is empty (and could be that the tifeatures deployment occurs at the same time) so I would think it makes sense to fail silently in these cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions