gitlab-exporter referencing database tables that don't exist
Summary
In v18.1.0, there were migrations for moving ci_pipelines and ci_job_artifacts to dynamic schema:
However, the gitlab-exporter seems to still refer to these tables. Example: https://gitlab.com/gitlab-org/ruby/gems/gitlab-exporter/-/blob/5ad17ca3018ad4551b2e33f6a67c33ac934efd39/lib/gitlab_exporter/database/ci_builds.rb#L27
Recently I responded to a customer ticket regarding a lot of PostgreSQL errors:
ERROR: relation "ci_job_artifacts" does not existERROR: relation "ci_pipelines" does not exist
Looking at the logs, we can see the same gitlab-exporter queries where these errors are reported:
2025-07-08_20:56:46.81505 ERROR: relation "ci_pipelines" does not exist at character 657
2025-07-08_20:56:46.81507 STATEMENT: SELECT
2025-07-08_20:56:46.81507 p_ci_builds.runner_id,
2025-07-08_20:56:46.81507 ci_runners.runner_type,
2025-07-08_20:56:46.81507 projects.namespace_id,
2025-07-08_20:56:46.81507 projects.mirror,
2025-07-08_20:56:46.81508 projects.mirror_trigger_builds,
2025-07-08_20:56:46.81508 ci_pipelines.pipeline_schedule_id,
2025-07-08_20:56:46.81508 p_ci_builds.trigger_request_id,
2025-07-08_20:56:46.81508 (COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) = 0 OR
2025-07-08_20:56:46.81508 COALESCE(namespace_statistics.shared_runners_seconds, 0) < COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) * 60) as has_minutes,
2025-07-08_20:56:46.81509 COUNT(*) AS count
2025-07-08_20:56:46.81509 FROM p_ci_builds
2025-07-08_20:56:46.81509 JOIN ci_runners
2025-07-08_20:56:46.81509 ON ci_runners.id = p_ci_builds.runner_id
2025-07-08_20:56:46.81509 JOIN projects
2025-07-08_20:56:46.81509 ON projects.id = p_ci_builds.project_id
2025-07-08_20:56:46.81510 JOIN ci_pipelines
2025-07-08_20:56:46.81510 ON ci_pipelines.id = p_ci_builds.commit_id
2025-07-08_20:56:46.81510 JOIN namespaces
2025-07-08_20:56:46.81510 ON namespaces.id = projects.namespace_id
2025-07-08_20:56:46.81510 LEFT JOIN namespace_statistics
2025-07-08_20:56:46.81510 ON namespace_statistics.namespace_id = namespaces.id
2025-07-08_20:56:46.81511 JOIN application_settings ON (TRUE)
2025-07-08_20:56:46.81511 WHERE p_ci_builds.type = 'Ci::Build'
2025-07-08_20:56:46.81512 AND p_ci_builds.status = 'running'
2025-07-08_20:56:46.81512 -- The created_at filter has been introduced for performance reasons only
2025-07-08_20:56:46.81512 AND p_ci_builds.created_at > NOW() - INTERVAL '7 days'
2025-07-08_20:56:46.81512 AND projects.pending_delete = 'f'
2025-07-08_20:56:46.81512 GROUP BY
2025-07-08_20:56:46.81513 p_ci_builds.runner_id,
2025-07-08_20:56:46.81513 ci_runners.runner_type,
2025-07-08_20:56:46.81513 projects.namespace_id,
2025-07-08_20:56:46.81513 projects.mirror,
2025-07-08_20:56:46.81513 projects.mirror_trigger_builds,
2025-07-08_20:56:46.81513 ci_pipelines.pipeline_schedule_id,
2025-07-08_20:56:46.81514 p_ci_builds.trigger_request_id,
2025-07-08_20:56:46.81514 namespaces.shared_runners_minutes_limit,
2025-07-08_20:56:46.81514 namespace_statistics.shared_runners_seconds,
2025-07-08_20:56:46.81514 application_settings.shared_runners_minutes
2025-07-08_20:56:46.81514
2025-07-08_20:56:46.81536 ERROR: relation "ci_job_artifacts" does not exist at character 135
2025-07-08_20:56:46.81536 STATEMENT: SELECT
2025-07-08_20:56:46.81536 COUNT(*) as count
2025-07-08_20:56:46.81536 FROM p_ci_builds
2025-07-08_20:56:46.81537 JOIN ci_build_trace_chunks
2025-07-08_20:56:46.81537 ON ci_build_trace_chunks.build_id = p_ci_builds.id
2025-07-08_20:56:46.81537 LEFT JOIN ci_job_artifacts
2025-07-08_20:56:46.81537 ON ci_job_artifacts.job_id = p_ci_builds.id
2025-07-08_20:56:46.81537 AND ci_job_artifacts.file_type = 3
2025-07-08_20:56:46.81537 WHERE p_ci_builds.type = 'Ci::Build'
2025-07-08_20:56:46.81538 AND p_ci_builds.status IN ('success', 'failed', 'canceled')
2025-07-08_20:56:46.81538 AND p_ci_builds.finished_at < '2025-07-07 13:56:46'
2025-07-08_20:56:46.81538 AND ci_job_artifacts.job_id IS NULL
We can see similar errors on GitLab.com relating to non-existent tables, where the username is postgres-exporter
https://log.gprd.gitlab.net/app/r/s/ZANFk