Our customer is having a very peculiar problem with our C#/ASP.NET application when they issue requests that access their Oracle XE 11g database. This happens via plain SQL over ADO.NET using the ODP.NET NuGet package.
Our application is hosted on a public server, while this particular database is hosted privately on customer's premises. I.e., we've been given a connection string with credentials and they've whitelisted our public IP in order for the application to see and communicate with their database.
The scheme works perfectly fine most of the time. There is, however, a certain set of queries (a single base query with slightly different parameters, actually) that cause a hang on the following line of C# code:
var reader = cmd.ExecuteReader(CommandBehavior.Default);
The SELECT is not trivial, but it isn't terribly complex, either:
SELECT "T00_".*
FROM (
SELECT ROWNUM "__ROWNUM",
"T0_".*
FROM (
SELECT "T1_"."FIELD1" "F1",
"T2_"."FIELD2" "F2",
"T3_"."FIELD3" "F3",
"T4_"."FIELD4" "F4"
FROM "TABLE1" "T1_"
LEFT OUTER JOIN "TABLE2" "T2_" ON ("T1_"."KEY2" = "T2_"."KEY")
LEFT OUTER JOIN "TABLE3" "T3_" ON ("T1_"."KEY3" = "T3_"."KEY")
LEFT OUTER JOIN "TABLE4" "T4_" ON ("T1_"."KEY4" = "T4_"."KEY")
ORDER BY "T1_"."KEY2",
"T1_"."KEY3"
) "T0_"
) "T00_"
WHERE "T00_"."__ROWNUM" <= 50
There are several hundred rows in TABLE1 and the above SELECT returns 50 of them, as expected. But changing it only slightly, e.g. requesting 62 rows instead of 50, or adding a field from one of the JOIN-ed tables to ORDER BY, is enough to cause a hang. No error, no timeout - the calling thread simply hangs forever on the ExecuteReader line.
We've experimented quite a lot, but the changes that cause the hang seem to make no particular sense.
The customer claims their other (local) applications have no problems with this database server and therefore the problem must be in our application. I'm inclined to agree, because all queries run fine when executed via TOAD. They only hang when executed from our application. I haven't been able to connect the dots yet...
The confusing part is, our ASP.NET application successfully retrieves data for our customers from a number of connected database engines, including other Oracle versions and I've seen no such problems there.
Has anyone else experienced a similar behavior with Oracle XE via ADO.NET? What do you suggest I try on our end? Telling the customer to switch databases is not an option at the moment.