On Wednesday, January 9, 2019 at 10:45:06 PM UTC-8, Jeremy Evans wrote:
>
> On Wednesday, January 9, 2019 at 5:12:09 PM UTC-8, Василий Колесников
> wrote:
>>
>> Hi all! Thanks for the great software!
>>
>> I came across a strange behavior: when I use `preconnect: :concurently`
>> option for connection then `server_logging` extension doesn't work.
>>
>> Here is an example:
>>
>> # frozen_string_literal: true
>>
>>
>> require 'bundler/inline'
>>
>>
>> gemfile(true) do
>> gem 'mysql2'
>> gem 'sequel'
>> end
>>
>>
>> require 'logger'
>> require 'sequel'
>>
>>
>> DATABASE_URL = URI('mysql2://[email protected]:3306/sequel_test')
>> LOGGER = Logger.new(STDOUT)
>> LOGGER.level = 0
>>
>>
>> DB = Sequel.connect(
>> DATABASE_URL.to_s,
>> servers: {
>> read_only: {
>> host: DATABASE_URL.host,
>> port: DATABASE_URL.port
>> }
>> },
>> extensions: %i[
>> error_sql
>> server_block
>> server_logging
>> connection_validator
>> ],
>> loggers: LOGGER,
>> log_connection_info: true,
>> preconnect: :concurrently,
>> max_connections: 10
>> )
>>
>>
>> DB.with_server(:default) do
>> DB[:users].count
>> end
>>
>>
> Thank you for the report. This issue occurs because preconnect does the
> connecting before loading extensions. In order to allow server_logging to
> work with preconnect, we would have to preconnect after loading extensions,
> and that change could potentially cause backwards compatibility issues (not
> sure which ones, but it's not a change I would make outside of a major
> version bump).
>
> To keep backwards compatibility, we would have to introduce an additional
> option. For lack of a better idea, let's call this
> preconnect_after_extensions. Can you test the following diff and see if it
> works for you:
>
I decided on a more flexible approach that will allow developers to choose
which extensions they would like loaded before preconnect and which they
would like loaded after:
https://github.com/jeremyevans/sequel/commit/bb3480a888a508f801d37bc642f7867258e6dc24
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.