Skip to content

feat(connection): add connection pool context awareness support - #19

Merged
vistart merged 5 commits into
release/v1.0.0.dev9from
feature/session-connection-pool
Apr 7, 2026
Merged

vistart merged 5 commits into
release/v1.0.0.dev9from
feature/session-connection-pool

Conversation

@vistart

@vistart vistart commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Description

Add connection pool context awareness support for PostgreSQL backend, enabling proper connection management across different execution contexts (sync/async, transaction boundaries).

This feature introduces:

  • Connection pool context providers: New providers that track and manage connection pool state across different test scenarios
  • Concurrent connection pool tests: Comprehensive test suite for validating thread-safe connection pool behavior
  • Testsuite integration: Provider interfaces for testing connection pool context awareness

Type of change

  • feat: A new feature
  • test: Adding missing tests or correcting existing tests
  • ci: Changes to our CI configuration files and scripts

Breaking Change

  • Yes
  • No

Applicable rhosocial-activerecord Version Range:

=1.0.0.dev9

Related Repositories/Packages

  • python-activerecord-testsuite: Requires coordinated changes for connection pool context awareness providers

Testing

  • I have added new tests to cover my changes.
  • All existing tests pass.
  • This change has been tested on PostgreSQL 12+ with psycopg 3.x

Test Plan:

  • Ran pytest tests/rhosocial/activerecord_test/feature/connection/ - connection pool concurrent tests
  • Ran pytest tests/rhosocial/activerecord_test/feature/basic/connection/ - basic connection context tests
  • Ran pytest tests/rhosocial/activerecord_test/feature/query/connection/ - query connection context tests

Commits in this PR

  1. 31382ec test(connection): add concurrent connection pool tests
  2. da68e8c feat: add connection pool context awareness providers
  3. 99b3155 feat: add testsuite connection pool context awareness tests
  4. 3aa88b5 ci: install dependencies from git instead of PyPI

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • I have added a Changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

This PR is part of the connection pool context awareness feature development cycle for v1.0.0.dev9.

vistart added 4 commits April 7, 2026 02:30
Add comprehensive tests for connection pool concurrency:

- Test concurrent connections are distinct
- Test concurrent operations don't cause deadlocks
- Test query results don't get mixed between connections
- Test concurrent transactions are properly isolated
- Add stress tests for high concurrent load

Both sync (BackendPool) and async (AsyncBackendPool) tests are included.
Implement IBasicConnectionProvider and IQueryConnectionProvider
for PostgreSQL backend to support testsuite connection pool tests.

- Add BasicConnectionProvider for feature.basic.connection tests
- Add QueryConnectionProvider for feature.query.connection tests
- Register both providers in registry.py
Import tests from testsuite for connection pool context awareness:

- feature/basic/connection/ - ActiveRecord context and CRUD tests
- feature/query/connection/ - ActiveQuery, CTEQuery, SetOperationQuery tests

These tests use the provider pattern to run backend-agnostic tests
defined in testsuite.
Change rhosocial-activerecord to git+https@release/v1.0.0.dev22
Change rhosocial-activerecord-testsuite to git+https@release/v1.0.0.dev9
@vistart vistart self-assigned this Apr 7, 2026
@vistart vistart added the feature label Apr 7, 2026
@codecov

codecov Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.70%. Comparing base (8cc66b5) to head (ee5695d).
⚠️ Report is 1 commits behind head on release/v1.0.0.dev9.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           release/v1.0.0.dev9      #19   +/-   ##
====================================================
  Coverage                71.70%   71.70%           
====================================================
  Files                      112      112           
  Lines                     6191     6191           
  Branches                   991      991           
====================================================
  Hits                      4439     4439           
  Misses                    1440     1440           
  Partials                   312      312           
Flag Coverage Δ
postgres-18 71.70% <ø> (ø)
python-3.14 71.70% <ø> (ø)
unittests 71.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vistart
vistart marked this pull request as ready for review April 7, 2026 09:15
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Apr 7, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 81e95bb into release/v1.0.0.dev9 Apr 7, 2026
14 checks passed
@vistart vistart mentioned this pull request Apr 8, 2026
3 of 11 tasks
vistart added a commit that referenced this pull request Apr 8, 2026
* test(connection): add concurrent connection pool tests

Add comprehensive tests for connection pool concurrency:

- Test concurrent connections are distinct
- Test concurrent operations don't cause deadlocks
- Test query results don't get mixed between connections
- Test concurrent transactions are properly isolated
- Add stress tests for high concurrent load

Both sync (BackendPool) and async (AsyncBackendPool) tests are included.

* feat: add connection pool context awareness providers

Implement IBasicConnectionProvider and IQueryConnectionProvider
for PostgreSQL backend to support testsuite connection pool tests.

- Add BasicConnectionProvider for feature.basic.connection tests
- Add QueryConnectionProvider for feature.query.connection tests
- Register both providers in registry.py

* feat: add testsuite connection pool context awareness tests

Import tests from testsuite for connection pool context awareness:

- feature/basic/connection/ - ActiveRecord context and CRUD tests
- feature/query/connection/ - ActiveQuery, CTEQuery, SetOperationQuery tests

These tests use the provider pattern to run backend-agnostic tests
defined in testsuite.

* ci: install dependencies from git instead of PyPI

Change rhosocial-activerecord to git+https@release/v1.0.0.dev22
Change rhosocial-activerecord-testsuite to git+https@release/v1.0.0.dev9

* chore: add changelog fragment for PR #19

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vistart
vistart deleted the feature/session-connection-pool branch April 9, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant