Skip to content

WIP: Introduce Gitlab::Database::ConnectionPool

username-removed-423915 requested to merge gitlab-connection-pool into master

This is a class where we could use in the migration, creating a database connection pool with arbitrary pool size. In general, the only use case would be:

Gitlab::Database::ConnectionPool.with_pool(2) do |pool|
  pool.execute_async('DELETE FROM table0;')
  pool.execute_async('DELETE FROM table1;')
  pool.execute_async('DELETE FROM table2;')
end

This would run the queries with ActiveRecord's with_connection and connection.execute in threads, and wait until all the queries are done, and finally gracefully close the connection pool.

@yorickpeterse Please review, thank you!

/cc @ayufan

Merge request reports