Fix table size script

What does this MR do?

It fixes our currently broken job for alerting on table size.

It refactors our script to leverage raw SQL instead of leveraging our PostresTableSize model which breaks every quarter, see successful job.

And now we are back with this alert which was triggered on deployment_merge_requests table.

Click to expand
DEPRECATION WARNING: ActiveRecord::ConnectionAdapters::ConnectionPool#connection is deprecated
and will be removed in Rails 8.0. Use #lease_connection instead.
 (called from <main> at table_size.rb:74)
/gitlab/lib/gitlab/database/shared_model.rb:44:in `connection': stack level too deep (SystemStackError)
	from /gitlab/lib/gitlab/database/shared_model.rb:53:in `connection_pool'
	from /gitlab/vendor/ruby/3.3.0/gems/activerecord-7.2.3/lib/active_record/connection_handling.rb:263:in `connection'
	from /gitlab/lib/gitlab/database/shared_model.rb:47:in `connection'
	from /gitlab/lib/gitlab/database/shared_model.rb:53:in `connection_pool'
	from /gitlab/vendor/ruby/3.3.0/gems/activerecord-7.2.3/lib/active_record/connection_handling.rb:263:in `connection'
	from /gitlab/lib/gitlab/database/shared_model.rb:47:in `connection'
	from /gitlab/lib/gitlab/database/shared_model.rb:53:in `connection_pool'
	from /gitlab/vendor/ruby/3.3.0/gems/activerecord-7.2.3/lib/active_record/connection_handling.rb:263:in `connection'
	 ... 11216 levels...
	from /gitlab/vendor/ruby/3.3.0/gems/activerecord-7.2.3/lib/active_record/relation.rb:558:in `_exec_scope'
	from /gitlab/vendor/ruby/3.3.0/gems/activerecord-7.2.3/lib/active_record/scoping/named.rb:175:in `block in scope'
	from table_size.rb:68:in `run'
	from table_size.rb:80:in `<main>'
Edited by Max Orefice

Merge request reports

Loading