Geo fix: ActiveRecord::StatementInvalid: PG::UndefinedColumn when querying reverification count
What does this MR do?
Fixes a PG::UndefinedColumn
error in Geo::ReverificationBatchWorker
that was causing the worker to fail on staging-ref and local GDK environments.
Problem
The Geo::ReverificationBatchWorker
was failing with ActiveRecord::StatementInvalid: PG::UndefinedColumn
errors when querying reverification counts for models with separate state tables.
Root Cause: The needs_reverification scope was attempting to query verified_at directly, but this column exists on the state table (e.g., upload_state) rather than the parent model table (e.g., upload). The scope verification_succeeded returns parent models, creating a mismatch when Rails tries to interpolate the SQL query.
Error Location: ee/app/models/concerns/geo/verification_state.rb:131 in needs_reverification_count
Solution
Updated the query to use verification_arel_table[:verified_at]
instead of verified_at to properly reference the state table column, resolving the SQL interpolation issue.
References
- !201298 (merged)
- https://gitlab.com/gitlab-org/gitlab/-/blob/v18.4.0-ee/ee/app/models/concerns/geo/verification_state.rb?ref_type=tags#L69
How to set up and validate locally
- Make sure your GDK setup is running Geo
- Navigate to
http://localhost:3000/admin/sidekiq/morgue
and witness the errors; - Checkout this MR's branch
- The error should stop appearing in Sidekiq's morgue
🎉
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.