You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using ARJDBC to connect to an AS/400. Once every while, maybe once in every 100000 executions, a query fails due to a quoting issue. As an example:
[2011-03-22 15:54:11] DEBUG ActiveRecord::Base: ActiveRecord::JDBCError: [SQL0206]
Column NP0001 not in specified tables.: SELECT cps.* FROM cps WHERE cps.c
omm_produkt_code = NP0001 ORDER BY cps.id DESC FETCH FIRST ROW ONLY
In this query, the NP0001 should have been quoted. This query is the result of the code:
CPS.where('comm_produkt_code' => some_variable)
The 'some_variable' always contains a String. If I run the exact same code again, immediately after such a failure, it succeeds, as it usually does. When I run the code again, the inputs, database and resulting paths through the code are exactly the same: there is no possibility that 'some_variable' is a String containing 'NP0001' sometimes, and some other datatype whose to_s results in 'NP0001' at other times. There are other queries, like
XYZ.find(some_string_id)
that fail in the same way, even though the input strings in those cases are literally constructed using a "foo #{bar} baz" construction, which couldn't possibly yield anything other than a string.
As a result, I'm guessing it must be a concurrency issue. That would explain the Schrodinger-nature of the issue and is somewhat suggested by the fact that I've only seen it happen when multiple threads were executing queries against the database and never during singlethreaded executions. Unfortunately, I haven't been able to reproduce the behaviour in a selfcontained piece of code that I could post here. From reading through the Arel and ARJDBC code, I haven't been able to discover any possibly threading issues, but I'm hoping this report causes someone else to go "Ah, yes, there is an issue there-and-there".
The text was updated successfully, but these errors were encountered:
I'm using ARJDBC to connect to an AS/400. Once every while, maybe once in every 100000 executions, a query fails due to a quoting issue. As an example:
In this query, the NP0001 should have been quoted. This query is the result of the code:
CPS.where('comm_produkt_code' => some_variable)
The 'some_variable' always contains a String. If I run the exact same code again, immediately after such a failure, it succeeds, as it usually does. When I run the code again, the inputs, database and resulting paths through the code are exactly the same: there is no possibility that 'some_variable' is a String containing 'NP0001' sometimes, and some other datatype whose to_s results in 'NP0001' at other times. There are other queries, like
XYZ.find(some_string_id)
that fail in the same way, even though the input strings in those cases are literally constructed using a "foo #{bar} baz" construction, which couldn't possibly yield anything other than a string.
As a result, I'm guessing it must be a concurrency issue. That would explain the Schrodinger-nature of the issue and is somewhat suggested by the fact that I've only seen it happen when multiple threads were executing queries against the database and never during singlethreaded executions. Unfortunately, I haven't been able to reproduce the behaviour in a selfcontained piece of code that I could post here. From reading through the Arel and ARJDBC code, I haven't been able to discover any possibly threading issues, but I'm hoping this report causes someone else to go "Ah, yes, there is an issue there-and-there".
The text was updated successfully, but these errors were encountered: