Monday, June 25, 2012

Re: [GCSQL] DatabaseError: 0: Connection is already in use

On Mon, Jun 25, 2012 at 4:38 PM, Jake Czyz <jjc.work@gmail.com> wrote:
Yes, that makes sense.  It pops up in a finally clause of a
try/except/finally block, which was meant to ensure tables are
unlocked in the event of other DB snafus.  I guess if the snafu is a
deadline exception,  I never see it because the finally gets executed
(and this error pops up) before the Deadline Exceeded is re-raised.

Thanks.  This still sucks, but at least I have a better understanding
of why.  Darn deadlines... :-)


I agree that it could be better.  If the query goes past its deadline, the Cloud SQL server will close the connection (and therefore release the locks) with the assumption that the application is long gone.  But that doesn't happen until the query completes.  Since mysql doesn't support deadlines, it would be better to snipe the query as soon as the host server detects that the query is past its deadline.  No promises there since that might be tricky to implement.

Here is a SO question that might be helpful for you in the meantime:
 

Ken



On Mon, Jun 25, 2012 at 7:32 PM, Ken Ashcraft <kash@google.com> wrote:
> This error typically happens when you have a deadline exceeded exception.
>  The app gives up, but the query is still running on the server.  If you try
> to do anything else with the connection, the server will complain that the
> connection is already in use.  So if you get the "connection already in use"
> error, it means that you probably have some place else in your code where
> you ignored the deadline exceeded exception and reused a connection.
>
> On Sat, Jun 23, 2012 at 5:47 AM, Jake Czyz <jjc.work@gmail.com> wrote:
>>
>> Hi Ken,
>>
>> Thanks, but could you please clarify?  Do you mean I need to catch
>> this error, recreate a connection and retry the same query?
>>
>> Jake
>>
>>
>>
>> On Fri, Jun 22, 2012 at 4:15 PM, Ken Ashcraft <kash@google.com> wrote:
>> > It means that the query is still executing on the server.  You need to
>> > throw
>> > away the connection and create a new one.
>> >
>> >
>> > On Fri, Jun 22, 2012 at 1:48 AM, Jake Czyz <jjc.work@gmail.com> wrote:
>> >>
>> >> Hello,
>> >>
>> >> My GAE app gets the following error occasionally during GC-SQL calls,
>> >> when unlocking previously locked tables.  Searching for the error
>> >> turned up nothing.  Does anyone have an idea about what could cause
>> >> it?
>> >>
>> >> <snip>
>> >>    cursor.execute('UNLOCK TABLES') #always unlock
>> >>  File "/base/python27_runtime/
>> >> python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
>> >> line 424, in execute
>> >>    self._DoExec(request)
>> >>  File
>> >>
>> >> "/base/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
>> >> line 355, in _DoExec
>> >>    response = self._conn.MakeRequest('Exec', request)
>> >>  File
>> >>
>> >> "/base/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
>> >> line 711, in MakeRequest
>> >>    response = self._MakeRetriableRequest(stub_method, request)
>> >>  File
>> >>
>> >> "/base/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
>> >> line 742, in _MakeRetriableRequest
>> >>    sql_exception.message))
>> >> DatabaseError: 0: Connection is already in use.
>> >>
>> >>
>> >> Thanks in advance,
>> >> Jake
>> >
>> >
>
>

No comments:

Post a Comment