Thanks so much, Jeremy.
I know the example was incomplete but, just expected a yes/no answer to
whether this was a known problem.
As for your proposed solutions, disabling streaming does solve the problem;
creating a new thread per #import call, apparently, does not. It errors
with:
Master::Ciudad(5): could not obtain a database connection within 5.000
seconds (waited 5.001 seconds)
As for the code in #import, sometimes it triggers queries for associations.
Wasn't aware of the problem, I'll look into that.
This is the full trace I was originally
seeing: https://gist.github.com/xymbol/df593a1b50ae10879853.
Thanks once again.
Regards
On Sunday, July 6, 2014 8:35:38 PM UTC-3, Jeremy Evans wrote:
>
> On Sunday, July 6, 2014 3:31:43 PM UTC-7, Adrian Mugnolo wrote:
>>
>> Hi,
>>
>> I'm seeing this issue with a .paged_each block that used to work. Right
>> now I'm using sequel 4.12.0, mysql2 0.3.16.
>>
>> Tracked the error to mysql2 code related to streaming being enabled. The
>> exception reads:
>>
>> Sequel::DatabaseError: Mysql2::Error: You have already fetched all
>> the rows for this query and streaming is true. (to reiterate you must
>> requery).
>>
>> This is the code fragment:
>>
>> def import(*args)
>> paged_each do |record|
>> begin
>> record.import(*args)
>> rescue => e
>> $stderr.puts "#{name}(#{record.pk.inspect}): #{e}"
>> end
>> end
>> end
>>
>> This code used to work with sequel 4.2.0, mysql2 0.3.13.
>>
>> Just wondering if this is a known issue or should try to further isolate
>> the problem.
>>
>
>
> You didn't provide a backtrace or an SQL log, and the example code you
> provided is not self-contained, so this is difficult to diagnose just by
> the example you provide. When trying to debug something, you don't want
> code that rescues exceptions and doesn't print the backtrace.
>
> The most likely issue is import is issuing a query, and you shouldn't be
> trying to issue a query on the same connection while iterating over the
> results of another query. However, that issue is not specific to
> streaming. If that is the issue, you could try using a separate thread to
> force another connection:
>
> Thread.new{record.import(*args)}.join
>
> If that fixes things, then that's the root cause of your issue. If it
> worked previously before paged_each used streaming, you were just getting
> lucky, as any time you issue a query on the same connection while iterating
> over the results of a previous query, you are firmly in the land of
> undefined behavior.
>
> The last time this code changed was in 4.9.0, when paged_each was changed
> to automatically use streaming. It's possible there are corner cases in
> mysql2's streaming support that make it not work with paged_each in all
> cases. You can disable the streaming support and see if that fixes it:
>
> Sequel::Mysql2::Dataset::STREAMING_SUPPORTED = false
>
> Even if that does fix it, I'd still like to try to figure out the root
> cause of why it doesn't work with streaming.
>
> If the earlier example of using a separate thread doesn't fix things,
> please put together a self contained example with a backtrace and SQL log
> and I'll try to debug.
>
> 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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.