﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37563	Oracle connection pool leaks unused pools during concurrent initialization	Patel Namraa	Patel Namraa	"The Oracle database backend can leak connection pools when multiple threads access the `pool` property concurrently during initialization.

In `django/db/backends/oracle/base.py`, the `pool` property checks whether a pool exists in `_connection_pools`, creates one using `Database.create_pool()`, and registers it using `setdefault()`.

If two threads access the property simultaneously, both can pass the initial membership check and independently create connection pools for the same pool key. Although `setdefault()` ensures that only one pool is registered, the pool created by the losing thread is discarded without being closed.

Unlike the PostgreSQL backend, which initializes its connection pool with `open=False` to avoid opening resources before registration, the Oracle backend creates its pool immediately. Consequently, the discarded pool may retain database sessions and other resources.

**Steps to reproduce:**

1. Configure the Oracle backend with connection pooling enabled.
2. Ensure that the connection pool has not yet been initialized.
3. Have two threads access the `pool` property concurrently.
4. Synchronize the threads so that both pass the initial dictionary membership check before either registers its pool.

Both threads can then create separate pool instances, but only one is retained in `_connection_pools`.

**Expected behavior:**

Concurrent initialization should not leave unused connection pools open. Any pool created but not registered should be properly closed.

**Actual behavior:**

The pool created by the losing thread is discarded without being explicitly closed, potentially leaking database sessions and other resources.

The PostgreSQL backend already avoids this issue by creating its pool with `open=False`, as documented in its initialization code.

This issue concerns concurrent connection-pool initialization within a process and is separate from connection-pool behavior across process forks."	Bug	assigned	Database layer (models, ORM)	dev	Low			Patel Namraa	Unreviewed	0	0	0	0	0	0
