Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS400/DB2: Occasional quoting issues #37

Closed
Confusion opened this issue Mar 25, 2011 · 3 comments
Closed

AS400/DB2: Occasional quoting issues #37

Confusion opened this issue Mar 25, 2011 · 3 comments
Labels

Comments

@Confusion
Copy link
Contributor

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".

@nicksieger
Copy link
Member

Your analysis seems sound. Unfortunately I'm not sure where to go with this, as I have no DB2 experience or access. Anyone else?

@kares
Copy link
Member

kares commented Aug 29, 2013

I'm closing this one - hopefully it's all fine now (there were no other user reports on these since) ... Thank you.

@kares kares closed this as completed Aug 29, 2013
@Confusion
Copy link
Contributor Author

I've never been able to reproduce this and at some point, probably after an upgrade of some or another, it just didn't happen anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants