Skip to content

Migration job fails with Table posthog.infi_clickhouse_orm_migrations doesn't exist #502

Open
@charlrvd

Description

Bug description

New installation of the chart fails on migrations. Therefore the deployment is not usable as the plugins, web, worker and events are not passing the init phase.

The SQL migrations run fine but soon after the following error happens

🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻
Skipping async migrations setup. This is unsafe in production!
🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺

AXES: BEGIN LOG
AXES: BEGIN LOG
AXES: Using django-axes version 5.9.0
AXES: Using django-axes version 5.9.0
AXES: blocking by IP only.
AXES: blocking by IP only.
Report for e1561f5b65f841e5cd9c5ccbee3d1a1f:
{'chart_version': '26.2.0',
 'cloud': 'aws',
 'deployment': 'helm_aws_ha',
 'deployment_type': 'helm',
 'hostname': 'posthog.domain',
 'ingress_type': 'nginx',
 'kube_version': 'v1.22.10-eks-84b4fe6',
 'operation': 'install',
 'posthog_version': '1.38.0',
 'release_name': 'posthog',
 'release_revision': 1}

🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻
Skipping async migrations setup. This is unsafe in production!
🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺

AXES: BEGIN LOG
AXES: BEGIN LOG
AXES: Using django-axes version 5.9.0
AXES: Using django-axes version 5.9.0
AXES: blocking by IP only.
AXES: blocking by IP only.
Operations to perform:
  Apply all migrations: admin, auth, axes, contenttypes, ee, posthog, rest_hooks, sessions, social_django
Running migrations:
  No migrations to apply.

🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻
Skipping async migrations setup. This is unsafe in production!
🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺

AXES: BEGIN LOG
AXES: BEGIN LOG
AXES: Using django-axes version 5.9.0
AXES: Using django-axes version 5.9.0
AXES: blocking by IP only.
AXES: blocking by IP only.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 362, in _get_applied_migrations_and_create_tables
    return self._get_applied_migrations(migrations_package_name, replicated)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 379, in _get_applied_migrations
    return set(obj.module_name for obj in self.select(query))
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 379, in <genexpr>
    return set(obj.module_name for obj in self.select(query))
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 276, in select
    r = self._send(query, settings, True)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 389, in _send
    raise ServerError(r.text)
infi.clickhouse_orm.database.ServerError: Code: 60. DB::Exception: Table posthog.infi_clickhouse_orm_migrations doesn't exist. (UNKNOWN_TABLE) (version 22.3.6.5 (official build))
 (0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/code/posthog/management/commands/migrate_clickhouse.py", line 42, in handle
    self.migrate(CLICKHOUSE_HTTP_URL, options)
  File "/code/posthog/management/commands/migrate_clickhouse.py", line 80, in migrate
    database.migrate(MIGRATIONS_PACKAGE_NAME, options["upto"], replicated=CLICKHOUSE_REPLICATION)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 346, in migrate
    applied_migrations = self._get_applied_migrations_and_create_tables(migrations_package_name, replicated=replicated)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 371, in _get_applied_migrations_and_create_tables
    return self._get_applied_migrations_and_create_tables(migrations_package_name, replicated, allow_missing_tables=False)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 359, in _get_applied_migrations_and_create_tables
    return self._get_applied_migrations(migrations_package_name, replicated)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 379, in _get_applied_migrations
    return set(obj.module_name for obj in self.select(query))
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 379, in <genexpr>
    return set(obj.module_name for obj in self.select(query))
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 276, in select
    r = self._send(query, settings, True)
  File "/usr/local/lib/python3.8/site-packages/infi/clickhouse_orm/database.py", line 389, in _send
    raise ServerError(r.text)
infi.clickhouse_orm.database.ServerError: Code: 60. DB::Exception: Table posthog.infi_clickhouse_orm_migrations doesn't exist. (UNKNOWN_TABLE) (version 22.3.6.5 (official build))
 (0)

Expected behavior

The installation completes after the migrations all runs to completion

Actual behavior

Migration fails to run on new deployment.

How to reproduce

Deploying the helm chart with

helm upgrade -install \
  -f values.yaml \
  --timeout 20m \
  --namespace posthog \
  posthog posthog/posthog \
  --wait --wait-for-jobs --debug

tried both in upgrade --install and just install but if fails with the same issues.

Environment

  • Deployment platform (AWS/Azure/DigitalOcean/GCP/...): AWS
  • k8s version (server version from kubectl version): 1.22
  • Chart version/commit (helm list -n posthog): 26.0.1 to 26.2.0
  • Posthog version: 1.38.0

Additional context

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions