Skip to content

Oracledb 2.4.1 Error DPY-4005 occurs when program works for a some time #402

@xsemashko

Description

@xsemashko
  1. What versions are you using?
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    platform.platform: Linux-4.18.0-553.el8_10.x86_64-x86_64-with-glibc2.28
    sys.maxsize > 2**32: True
    platform.python_version: 3.12.3
    oracledb.version: 2.4.1
  1. Is it an error or a hang or a crash?
    Error

  2. What error(s) or behavior you are seeing?
    At the beginning program works fine for a first ~1-2 minutes or 1-3 pool.acquire() requests. Then error "DPY-4005: timed out waiting for the connection pool to return a connection" occurs. When I check pool on db with "select * from v$session where MACHINE = 'server name' and USERNAME = 'username'" I see 5 free connections from pool, it's fine.

  1. Does your application call init_oracle_client()?
    NO
  1. Include a runnable Python script that shows the problem.
    Here I made 2 examples which doesn't have any sense but shows structure of my application. First example with concurrent.futures second just with multiprocessing. I acquire connection and use it inside current process and declare pool as global and in my oppinion it must work.

First example

import oracledb, time, traceback
from multiprocessing import Process
import concurrent.futures as pool
from itertools import repeat

ora_pp = oracledb.PoolParams(min=5, max=10, increment=0)
ora_pool = oracledb.create_pool(user='', password="", host='', port=, service_name="", params=ora_pp, getmode=oracledb.POOL_GETMODE_TIMEDWAIT)
#Time for pool creation. It dial with DB futures
time.sleep(1)
ora_pool.wait_timeout=4000

def parallel_oracle_processing(record,i):
	try:
		with ora_pool.acquire() as conn:
			with conn.cursor() as cur:
				print('connected')
				select = f"select ID from ows.acnt_contract where id = '{record}'"
				cur.execute(select)
				data = cur.fetchone()
		return(data)
	except:
		print('disconnected')
		print(traceback.format_exc())

def inqBalanceList():
	data_list = range(0, 5)
	records = [5,6,8,11,14]
	for record in records:
		with pool.ThreadPoolExecutor(max_workers=5) as executer:
			res = executer.map(parallel_oracle_processing, repeat(record), data_list)
		results = list(res)
		print(results)

def getter():
	while 1:
		producer_process = Process(target=inqBalanceList)
		producer_process.start()
		time.sleep(3)

if __name__ == '__main__':
	p = Process(target=getter)
	p.start()

Second example

import oracledb, time, traceback
from multiprocessing import Process
import concurrent.futures as pool
from itertools import repeat

ora_pp = oracledb.PoolParams(min=5, max=10, increment=0)
ora_pool = oracledb.create_pool(user='', password="", host='', port=, service_name="", params=ora_pp, getmode=oracledb.POOL_GETMODE_TIMEDWAIT)
#Time for pool creation. It dial with DB futures
time.sleep(1)
ora_pool.wait_timeout=4000

def oracle_processing():
	record = 5
	try:
		with ora_pool.acquire() as conn:
			with conn.cursor() as cur:
				print('connected')
				select = f"select ID from ows.acnt_contract where id = '{record}'"
				cur.execute(select)
				data = cur.fetchone()
		return(data)
	except:
		print('disconnected')
		print(traceback.format_exc())

def inqBalanceList():
	data = oracle_processing()
	print(data)

def getter():
	while 1:
		producer_process = Process(target=inqBalanceList)
		producer_process.start()
		time.sleep(3)

if __name__ == '__main__':
	p = Process(target=getter)
	p.start()

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions