infiniflow / infiniflow/infinity

[Feature Request]: Infinity python sdk connection need reference count

Open
#1,820 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
4.7k
Forks
445
Avg merge
2d 2h
Merged PRs (30d)
7

Description

### Is there an existing issue for the same feature request?

- [X] I have checked the existing issues.

### Is your feature request related to a problem?

_No response_

### Describe the feature you'd like

`ConnectionPool` current usage example:

```
def random_exec(connection_pool: ConnectionPool, data, end_time, thread_id):
infinity_obj = connection_pool.get_conn()
db_obj = infinity_obj.get_database("default_db")
table_obj = db_obj.get_table("chaos_test")
# use table_obj here
# If an exception is raised here, the connection will not gc by the connection pool.
connection_pool.release_conn(infinity_obj)
```

My suggestion is:
`ConnectionPool.get_conn()` returns a `PooledConn`. Its `__del__` calls `ConnectionPool.release_conn()` to return the connection to pool.

### Describe implementation you've considered

_No response_

### Documentation, adoption, use case

_No response_

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the Python SDK's ConnectionPool implementation and the get_conn(), release_conn(), and proposed PooledConn entry points. Check how connections are currently returned when an exception interrupts use. Done means a PooledConn returns its connection to the pool when discarded, including the shown exception path, without requiring an explicit release_conn() call.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.