THIS. Many many thanks @cmwebdev !!
In my previous attempts I had also set the connection request like that:
Mysql2::Client.new(host: options.host, username: options.username,
password: options.password, database: options.database,
read_timeout: 3600, write_timeout: 3600, connect_timeout: 3600,
reconnect: true)
but what definitively did the trick was to tune the mysql server configuration to maximise buffers and timeouts.
I’m noting down all I’m doing and in a few days I’ll post a comprehensive guide to SMF2 migration.