v0.52 Improve handling and look at how we can improve ActiveRecord config for PostgreSQL and avoid insufficient pool size

This commit is contained in:
David Sainty 2024-08-19 22:21:16 +10:00
parent 6360e99a96
commit bcc7519d78

View File

@ -1075,10 +1075,10 @@ class GossamerForumsImporter < ImportScripts::Base
# Get list of TOPICS / OP posts, i.e. post ids that have no parent / root id - SELECT post_id FROM gforum_Post WHERE post_root_id = 0;
def threaded_topic_import
# Update connection pool settings
ActiveRecord::Base.establish_connection(
ActiveRecord::Base.connection_db_config.configuration_hash.merge(pool: 40, timeout: 5000)
)
## # Update connection pool settings
## ActiveRecord::Base.establish_connection(
## ActiveRecord::Base.connection_db_config.configuration_hash.merge(pool: 40, timeout: 5000)
## )
### # Define the custom connection pool settings
### custom_pool = ActiveRecord::ConnectionAdapters::ConnectionPool.new(
@ -1184,9 +1184,9 @@ class GossamerForumsImporter < ImportScripts::Base
end
# Use connection pooling for PostgreSQL and synchronize access to shared resources
# ActiveRecord::Base.connection_pool.with_connection do
ActiveRecord::Base.connection_pool.with_connection do
# ActiveRecord::Base.connected_to(pool: 'CustomPool') do
ActiveRecord::Base.connected_to(role: :writing) do
## ActiveRecord::Base.connected_to(role: :writing) do
post_status = fetch_post_status(post_id)
if post_status.nil? || post_status == 0
puts "Starting import for post_id #{post_id}"
@ -1514,7 +1514,7 @@ class GossamerForumsImporter < ImportScripts::Base
rescue ActiveRecord::RecordInvalid => e
puts "---> ERROR importing topic with post_id #{row['post_id']}: #{e.message}"
# raise ActiveRecord::Rollback
raise ActiveRecord::Rollback
end
# end
else