Skip to content

Use fully qualified modules in connection proxy

Heinrich Lee Yu requested to merge db-load-balancer-code-reloading into master

What does this MR do?

An instance of this class is stored in memory in a class instance variable. When this class is stale, it causes code-reloading issues when Gitlab::Database::LoadBalancing::ConnectionProxy.const_missing is triggered.

This is a workaround so that Object.const_missing is triggered instead.

This is similar to !31512 (merged)

Sample stacktrace:

Puma caught this error: A copy of Gitlab::Database::LoadBalancing::ConnectionProxy has been removed from the module tree but is still active! (ArgumentError)
/usr/local/Cellar/asdf/0.7.6/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:530:in `load_missing_constant'
/usr/local/Cellar/asdf/0.7.6/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:61:in `block in load_missing_constant'
/usr/local/Cellar/asdf/0.7.6/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:17:in `allow_bootsnap_retry'
/usr/local/Cellar/asdf/0.7.6/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `load_missing_constant'
/usr/local/Cellar/asdf/0.7.6/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:214:in `const_missing'
/Users/engwan/Projects/gdk/gitlab/ee/lib/gitlab/database/load_balancing/connection_proxy.rb:67:in `read_using_load_balancer'
/Users/engwan/Projects/gdk/gitlab/ee/lib/gitlab/database/load_balancing/connection_proxy.rb:42:in `select_all'

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Heinrich Lee Yu

Merge request reports