On Fri, Nov 12, 2021 at 1:35 PM Jeffrey Stuart <[email protected]>
wrote:

> We are using sequel 4.49.0 with delayed_job 4.1.9.
>
> Ubuntu 20.04
> Ruby 2.6.4
> Rvm 1.29.12
>
> When we include a logger in the delayed_job startup script the job
> succeeds.  When we do not include a logger in the delayed_job startup
> script we get the error (full stack attached):
> Mysql2::Error: Got packets out of order
>

Could be the logger just changes the timing so you don't hit the race
condition.  However, that's just a guess, and not an educated one.


> The mysql2 team wrote back with:
>
> You may be sharing a single connection between multiple threads or child
> processes; this can be OK as long as you manage locking. Each database
> connection is stateful, so you have to make sure that it goes through a
> complete login-query-fetchresults-freeresults cycle before another thread
> can use it.
>
> The mysql2 gem does not have a database connection pool manager built-in,
> usually people use ActiveRecord for this purpose. I'm not as familiar with
> Sequel, but it should have something to help manage a connection pool.
>
> Sequel maintains a thread-safe connection pool by default.  However, there
are definitely ways you can run into this issue, such as issuing new
queries inside a Dataset#each block (as documented in that method).


> When a delayed_job worker is launched I see two threads start and go away
> when the job is completed.
>
> Below is a snippet of the delayed_job startup script with the logger.
> Sequel.connect(db_config)
> logger = Logger.new('/var/log/adhearsion/test.log')
> Delayed::Worker.backend = :sequel
> Delayed::Worker.destroy_failed_jobs = false
> Delayed::Worker.sleep_delay = 10
> Delayed::Worker.max_attempts = 15
> Delayed::Worker.max_run_time = 1.hour
> arguments = ['--pid-dir=/var/run/adhearsion', '--log-dir=/tmp',
> "--queue=#{this_host}"]
> arguments.concat(ARGV)
> Delayed::Command.new(arguments).daemonize
>
> I'm perplexed as to why the inclusion of a logger allows the delayed_job
> to succeed.  Also, I'm not sure whether this is a sequel or delayed_job
> issue.  Any information you can provide would be greatly appreciated.
> Thanks
>

If you can provide a self contained example showing the issue without
delayed_job and with the current version of Sequel, I can probably help
debug.  I will say that based on similar cases previously reported, issues
like this are usually caused by incorrect usage and not bugs in Sequel.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSe%2B%2BnkkF9y877kRiSbFAycaPXQn%3Dr%3Ds6nGg%3DLZQNw-WbQ%40mail.gmail.com.

Reply via email to