oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

Failover not working correctly #328

Open Hrafnkellos opened 2 months ago

Hrafnkellos commented 2 months ago

What versions are you using?

2.1.2

Give your database version.

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production


    import sys
    import platform

    print("platform.platform:", platform.platform())
    print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
    print("platform.python_version:", platform.python_version())

platform.platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.31 sys.maxsize > 2**32: True platform.python_version: 3.10.13


    import oracledb
    print("oracledb.__version__:", oracledb.__version__)

oracledb.version: 2.1.2

Is it an error or a hang or a crash?

Its an error

What error(s) or behavior you are seeing?

When I configure my connections string to failover and then take down one oracle RAC Instance the OracleDB does not switch to the other RAC Instance that is alive. Instead I get the error "Error Message: ORA-01109: database not open"

Mostly I was testing with 2 host and one dead host. I indicated the dead host first. If I switch orders of hosts then oracleDB tries to connect to the first host and successfully connects.

Cut and paste text showing the command you ran. No screenshots.

Here is an example connection string

(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=5)(CONNECT_TIMEOUT=5)(RETRY_DELAY=10)(RETRY_COUNT=2)(FAILOVER=ON)(LOAD_BALANCE=off)(ADDRESS=(PROTOCOL=TCP)(HOST=OracleRACInstance1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=OracleRACInstance1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DemoServiceName)))

Does your application call init_oracle_client()?

Yes

This tells us whether you are using the python-oracledb Thin or Thick mode.

I tried both Thin and Thick mode. It had the same result.

Include a runnable Python script that shows the problem.

import oracledb 
import environ

def start_pool():
    # Generally a fixed-size pool is recommended, i.e. pool_min=pool_max.  Here
    # the pool contains 4 connections, which will allow 4 concurrent users.

    pool_min = 4
    pool_max = 4
    pool_inc = 1

    pool = oracledb.create_pool(
        user=env('DATABASE_USER'), 
        password=env('DATABASE_PASSWORD'), 
        dsn=env('DATABASE_NAME'), # I added my connection string here
        min=pool_min,
        max=pool_max,
        increment=pool_inc,
        events=True,
    )