I have a test environment with an Oracle 10XE database which is linked to an SQL-Server 2005 via an ODBC data source. For reference here I named the connection MSSQL_LINK
. The production environment will have an Oracle 11g and an SQL-Server 2008. The connection once set up works fine.
As a test of error conditions in production we unplugged the network cable. This broke the connection. A subsequent executed statement (e.g. select * from test_table@MSSQL_LINK;
) failed with an error ORA-28500, which is a wrapper for the original ODBC error:
[Generic Connectivity Using ODBC][S1000] [9013]General error in nvITrans_BeginT - rc = -1. Please refer to the log file for details.
ORA-02063: preceding 2 lines from MSSQL_LINK
This was somewhat expected. Unfortunately plugging the cable back into the machine does not lead to an automatic reconnect of the link. The problem persists until I drop the link and create it anew with the commands
drop database link MSSQL_LINK;
create database link MSSQL_LINK connect to "user" identified by "passwd" using 'MSSQL_LNK';
Also the same happens if I just disconnect the cable for a short time and reconnect it before I execute any statements over the link. The interim breakup is still detected by the ODBC driver but not fixed on its own.
As mentioned by Ste, creating a link will tell Oracle only about the connection parameters like host, user name, password, but not create a connection by itself. The link can be created without the network cable connected to the Oracle machine. If I create the link without the cable connected, then connect it to and execute a simple select on the linked server, the same Oracle error occurs.
Obviously in production mode this is an unacceptable situation which needs to be fixed, preferably by an automatic procedure.
Three questions do I have about this:
- Is there a way to test a database link other than e.g. a select on a test table which resides on the linked server?
- Is dropping an re-creating the database link on my oracle machine the best option I have when this problem occurs?
- What is the best automatic procedure for recovering from this situation.
Best Answer
Step by step:
select sysdate from dual@dblink
. A firewall is in place between both databases. Source DB opens the connection, retrieve data and leave connection opened. After 15mins the firewall drop the connection. At minute 20 another user performs the same query. The database will reopen the connection.Apart from this I understand that you get the connection dropped and you have to way to re-establish it without drop and recreate the database. Metalink (formerly My Oracle Support) suggest to check if
HS=OK
is correctly set in the tnsnames.ora. Attention: theHS=OK
argument needs to be outside of theCONNECT_DATA
portion of the entry. Here an example:Moreover I suggest you to check (and eventually post) logs on both sides. You can also increase the level of
HS_FDS_TRACE_LEVEL
parameter. In addition MOS reports some issue with DG4ODBC and suggest to debug them (and fill a bug if necessary) using trace on the ODBC layer.