OCISessionBegin hangs in multithreaded COM+ applications [Delphi + ODAC + Oracle] - oracle

We have here a application that uses ODAC components inside COM+ dlls to connect to Oracle Server 11g.
Lately we are facing a problem that we cannot find the solution.
For some reason, when the concurrency of the application server at some of our clients is too high, some dlls starts to hang and they have to kill the process to restore the usability of our product. Trying to reproduce the error here at our office, we created a test environment to stress an application server. We start 30-50 programs that make calls to application and after some time the problem appears.
Debugging our DLL after the server hangs, shows that any subsequent call to OCISessionBegin cannot complete. No error is generated. No other symptoms are visible.
The last line that the we try to execute is: Check(OCISessionBegin(...)); on OraClasses.pas
We checked the database no contention, no lock.
We are using ODAC 6 on our clients, but we upgraded it to the last version and the problem persists. We have to use the Oracle Client 10 to connect to the database 11g because the are using the version 6 of ODAC.
Thanks a lot

AFAIK you need to create your environment with both OCI_EVENTS + OCI_THREADED attributes sets, in such a configuration.
For instance, here is how it is initialized in our Open Source direct Oracle access unit:
fEnvironmentInitializationMode := OCI_EVENTS or OCI_THREADED;
...
with OCI do
try
if fEnv=nil then
// will use UTF-8 encoding by default, in a multi-threaded context
// OCI_EVENTS is needed to support Oracle RAC Connection Load Balancing
EnvNlsCreate(fEnv,Props.EnvironmentInitializationMode,
nil,nil,nil,nil,0,nil,OCI_UTF8,OCI_UTF8);
I suspect you have to check how your OCI environment is created in ODAC.

Related

Issue with Oracle Client Data Source in SQL Server 2012 SSIS

I am having an issue with Oracle connectivity from an SSIS project, and have been Googling around to try to find a solution for over a week, now, and haven't found anything.
I have the following configuration in my dev environment:
O/S: Windows Server 2008 R2 Datacenter, 64-bit
SQL Server Data Tools, 2010
I need to configure an SSIS Data Flow Task to pull data from four different Oracle Data Sources (among others). One is Oracle version 11.1.0.7, two are version 9.2.0.4.0 and one is 9.2.0.8.0.
We use local TNSNAMES and SQLNET.ora files for our configuration.
I have tried this with many different Oracle clients, and basically get the same result, so will highlight one that I did:
Installed the Oracle Client 11gR2 64 bit.
Installed the Oracle Client 11gR2 32 bit (that order is recommended).
Copied my TNSNAMES and SQLNET.ora files into both network/admin configuration folders.
Did a successful TNSPING on each of the 4 databases named above. Successful.
Opened up SQL Server Data Tools and opened a new project
Did a "Create new Connection Manager", picked ADO.NET
Selected "Oracle Client Data Provider", enter the details of the 11g database
Did a "test Connection". Success.
Repeat the procedure for one of the 9.0 databases. When I do the "Test Connection" I get a "Test Connection failed because of an error in initializing provider. ORA-12645: Parameter does not exist".
I get this same result for all three of the 9.x databases.
Oracle "help" says that this error is caused by a missing parameter in the SQLNET.ora file, and that the solution is to add the missing parameter. Trouble is, nowhere does it say what is missing.
I have tried this same procedure with other Oracle client installs other than the two clients - ODTwithODAC1120320_32 bit, ODAC1120320_x64 and get exactly the same result. I can't go to a version 12 client because as I understand it, it won't work with a 9 database. I can't go to a 10 client because that won't work with an 11 database.
I have a feeling that it's very specific to the 64-bit O/S and version of SQL server, but that is our target platform, so need to make it work.
Can anyone help me with this, please?

TNS,can not handle the service name when two different version installed together

In our server,we publish a asp.net application,which use the oracle11g as the database.
We just set the connection string in the web.config,it works.
However someone install the oracle8 in the same server since they need them in other client application.
But after that,our web applcation can not work,we get the error:
ora-12154 TNS an not handle the service name
Then I found that the path environment has been changed. The "C:/app/oracle81/bin" is added at first. But even I change the "D:/app/oracle11g/bin" first,it does not work also.
Any idea to make the both work?
You might investigate what drivers are being used within .NET ... Microsoft's deprecated Oracle provider or Oracle's own provider or some kind of ODBC provider sitting on top of several kinds of possible drivers in a DSN. Each might be remedied in a different way.
But it sounds like the Oracle 8 installation has stolen priority over the Oracle 11 installation in some way that is not just the "PATH" environment variable. My guess would be the registry.
In ascending order of inconvenience and effectiveness you could try:
1) Run the Oracle 11 installer and see if it knows about the Oracle 8 home. (Unlikely if it's 8.0). Set it as default or top of the list; exit; then go back and set Oracle 11 as the default/top of the list.
2) Configure the TNS entries in your Oracle 8 home to connect to your Oracle 11 database. Live with the fact you're using a very out of date client.
3) Uninstall and reinstall Oracle 11 to get it to steal back the priority.
By default the .net framework uses the FIRST oracle directory it comes to the in the path statement. There have been some discussions on how to get around this - but your best bet is to run one client per machine.

Embedded or managed Oracle instance for integration tests

For MySQL, the MXJ connector makes it very easy to launch a managed MySQL instance.
I know that Oracle provides Oracle XE for quick setup, but I've only found an RPM distribution that needs to be installed. Is there a neatly packaged jar that I can just drop in the classpath and start up by calling a specific JDBC url, a la HSQLDB or MXJ?
I'm interested in having developers use this locally for running tests, as well as on our continuous integration server.
The short answer is No. Oracle is a big meaty chunk of database. Amongst other things, it generally expects itself to be run by its own special user rather than the client user.
For simplicity, your best bet is a separate DB server with each of your developers having their own username/password (and hence their own independent schema) in the database.
Although Oracle does not provide an embedded database, spinning up a local Docker container running Oracle XE might be an ideal way to accommodate Oracle-specific local integration tests. Since Docker containers are ephemeral in nature by design, the database could also be completely torn down as desired providing clean sandboxing.
The alexeiled/docker-oracle-xe-11g image on DockerHub I found has particularly clear setup and documentation instructions: https://hub.docker.com/r/alexeiled/docker-oracle-xe-11g/
After spinning up the Docker container, be sure to:
First connect to the APEX web console, login, as per the instructions
Then open Oracle SQL Developer and select Reset Password... first. Otherwise the following error may be thrown java.lang.ArithmeticException when attempting to get connection in Oracle 11.2.0.2.0 (64 bit)
As the documentation describes, the docker run command can also be designed to automatically run SQL scripts on the container's startup, which could also be very valuable in the CI/integration testing workflow.
Hope this helps!

Closing all connections to a particular database without downing the whole service

We have some databases in a single SQL Server 2000 instance, one of them being a sandbox. My boss needs to be able to restore fresh data over the sandbox using a utility I don't have the source to. Such restores fail if anyone is connected to the sandbox.
Another app I have accessing it uses connection pooling, and also there might be people using other apps to access the sandbox that I can't control.
How can I boot everyone off the sandbox, including the pooled connections, without touching any of the other databases running on the same instance?
(I've seen solutions out there that use Management Studio 2008 (from 2008 Express), but a) I need to be able to do it from the command line or a script somehow so my boss can run it without installing Management Studio, and b) the context menu options they talked about didn't seem to be there anyway.)
I've found it on the web:
ALTER DATABASE db SET SINGLE_USER WITH ROLLBACK IMMEDIATE
create a sp that run this restores, and then restore it to regular.
(ALTER DATABASE foo SET MULTI_USER;)

How do I fix a broken connection to DB2 from a web application?

I support some old web applications, VBScript-based ASP for the UI and VB6 COM modules for the business and data access layers. Last weekend, I installed DB2 Connect Enterprise Edition v8 fixpack 14 on several Windows 2000 servers, and one of the web apps errors out on null data when it calls the built in VBScript function FormatNumber. This numeric data is retrieved by a SQL Server query, but the only way the SQL Server column is populated is with the calculated results returned from a DB2 query earlier in a progression through several pages.
When I installed DB2 Connect EE, one of the components loaded was MDAC 2.7. I followed corporate instructions and had the installation save an ODBC System Data Source, which reported a good connection when I tested it after the install.
For what it's worth, the project references in the production VB6 modules pointed to MDAC 2.5. I have tried recompiling and deploying to COM on my test server new versions of the VB6 modules referencing MDAC 2.7. My development environment is Windows XP Pro, with MDAC 2.8 and DB2 Connect EE v9.5 installed. When I deployed the updated VB6 dlls, the CreateObject fails to instantiate the classes with the error message that "The class does not support automation or the requested interface".
I've rolled the DB2 Connect install back and have reinstall v8 of the DB2 runtime client, which was the previous environment. The problem, however, persists.
I don't really get the picture for how things are connected together - where is the SQL Server and where is the DB2.
There are forums on IBM's site for helping out specifically with DB2 Connect EE, wwhich I think is a pretty pricey product (not sure tho).
One way I have seen people do it is configure a SQL server as the data gateway. You can define DB2 as a linked server, and then perform SQL queries through the SQL server in order to get to DB2. Apps need only to be able to connect to SQL Server, not directly to DB2. They get to DB2 indirectly. Depending on the load on the system this may or may not be feasible for you. You can even do joins across data stored separately in DB2 and SQL with this approach.
It's one more option in the toolbox, along with replication, data federation, and so on. I found that it reduces the variability in connectivity.

Resources