v0.49 Work on MySQL brokenness
This commit is contained in:
parent
cdd512bf06
commit
e6a4ec5623
@ -1156,33 +1156,32 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
|
||||
# Submit the import job for the current post_id to the thread pool
|
||||
pool.post do
|
||||
# Initialise a new MariaDB / Mysql2 client inside of each thread
|
||||
#### mysql_client = Mysql2::Client.new(
|
||||
#### host: "slowtwitch.northend.network",
|
||||
#### username: "admin",
|
||||
#### password: "yxnh93Ybbz2Nm8#mp28zCVv",
|
||||
#### database: "slowtwitch"
|
||||
#### )
|
||||
#### puts "PP 22 -- #{post_id}"
|
||||
|
||||
begin
|
||||
mariadb_pool.with do |mysql_client|
|
||||
####### mariadb_pool.with do |mysql_client|
|
||||
|
||||
# Initialise a new MariaDB / Mysql2 client inside of each thread
|
||||
mysql_client = Mysql2::Client.new(
|
||||
host: "slowtwitch.northend.network",
|
||||
username: "admin",
|
||||
password: "yxnh93Ybbz2Nm8#mp28zCVv",
|
||||
database: "slowtwitch"
|
||||
)
|
||||
# Ensure the connection is active, otherwise reconnect
|
||||
puts "PP 11 -- #{post_id} -- Checking MySQL connections status.."
|
||||
mysql_client.ping
|
||||
## || mysql_client = Mysql2::Client.new(
|
||||
## host: "slowtwitch.northend.network",
|
||||
## username: "admin",
|
||||
## password: "yxnh93Ybbz2Nm8#mp28zCVv",
|
||||
## database: "slowtwitch"
|
||||
## )
|
||||
#### puts " FIRST Checking MySQL connection status..."
|
||||
#### if mysql_client.query('SELECT 1').nil?
|
||||
#### puts " MySQL connection is not valid"
|
||||
#### else
|
||||
#### puts " MySQL connection is valid"
|
||||
#### end
|
||||
mysql_client.ping || mysql_client = Mysql2::Client.new(
|
||||
host: "slowtwitch.northend.network",
|
||||
username: "admin",
|
||||
password: "yxnh93Ybbz2Nm8#mp28zCVv",
|
||||
database: "slowtwitch"
|
||||
)
|
||||
puts " FIRST Checking MySQL connection status..."
|
||||
if mysql_client.query('SELECT 1').nil?
|
||||
puts " !! MySQL connection is NOT VALID !!"
|
||||
else
|
||||
puts " MySQL connection is valid"
|
||||
end
|
||||
|
||||
# Use connection pooling for PostgreSQL and synchronize access to shared resources
|
||||
ActiveRecord::Base.connection_pool.with_connection do
|
||||
@ -1197,7 +1196,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
puts "Skipping post_id #{post_id}, already processed."
|
||||
end
|
||||
end
|
||||
end
|
||||
####### end
|
||||
rescue => e
|
||||
puts "Error processing post ID #{post_id}: #{e.message}"
|
||||
puts e.backtrace.join("\n") # Print the full stack trace
|
||||
@ -1209,17 +1208,10 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
puts "Reconnecting to MySQL for post ID #{post_id} due to connection loss..."
|
||||
retry
|
||||
end
|
||||
#### ensure
|
||||
#### # Ensure the MariaDB connection is closed after processing
|
||||
#### mysql_client.close if mysql_client
|
||||
#### puts "** CLOSED MariaDB client"
|
||||
#### puts "PP 22 -- #{post_id}"
|
||||
#### puts " FINAL Checking MySQL connection status..."
|
||||
#### if mysql_client.query('SELECT 1').nil?
|
||||
#### puts " MySQL connection is not valid"
|
||||
#### else
|
||||
#### puts " MySQL connection is valid"
|
||||
#### end
|
||||
ensure
|
||||
# Ensure the MariaDB connection is closed after processing
|
||||
mysql_client.close if mysql_client
|
||||
puts "** CLOSED MariaDB client"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user