Skip to content

Fix/db connection pool limit#743

Merged
Prajna1999 merged 6 commits intomainfrom
fix/db-connection-pool-limit
Apr 9, 2026
Merged

Fix/db connection pool limit#743
Prajna1999 merged 6 commits intomainfrom
fix/db-connection-pool-limit

Conversation

@Prajna1999
Copy link
Copy Markdown
Collaborator

@Prajna1999 Prajna1999 commented Apr 9, 2026

Summary

Target issue is #PLEASE_TYPE_ISSUE_NUMBER
Explain the motivation for making this change. What existing problem does the pull request solve?

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

Summary by CodeRabbit

  • Chores
    • Enhanced background task system monitoring with expanded logging during task completion and failure scenarios, providing improved visibility into system health and troubleshooting capabilities.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec7e62d2-a66b-430a-af63-08efbb846a38

📥 Commits

Reviewing files that changed from the base of the PR and between 1e81ff0 and 04f5e79.

📒 Files selected for processing (1)
  • backend/app/celery/celery_app.py

📝 Walkthrough

Walkthrough

The change extends Celery signal handling to monitor SQLAlchemy connection pool metrics at additional task lifecycle points. Handlers are added for task completion and failure events to log pool status alongside existing pre-run logging.

Changes

Cohort / File(s) Summary
Celery Signal Handlers
backend/app/celery/celery_app.py
Extended signal imports to include task_failure and task_postrun. Added log_pool_status_post handler connected to task_postrun to log QueuePool metrics (checked out count, pool size, overflow) after task completion. Added log_pool_status_failure handler connected to task_failure to emit warning with pool metrics, task name/id, and exception type on task failure.

Sequence Diagram

sequenceDiagram
    participant CeleryWorker as Celery Worker
    participant Task as Task Execution
    participant Signals as Celery Signals
    participant QueuePool as SQLAlchemy<br/>QueuePool
    participant Logger as Logger

    CeleryWorker->>Task: Start Task
    Task->>Signals: Emit task_prerun
    Signals->>QueuePool: Query pool metrics
    QueuePool-->>Logger: log_pool_status (pre-run)
    
    Task->>Task: Execute
    
    alt Task Completes
        Task->>Signals: Emit task_postrun
        Signals->>QueuePool: Query pool metrics
        QueuePool-->>Logger: log_pool_status_post (post-run)
    else Task Fails
        Task->>Signals: Emit task_failure
        Signals->>QueuePool: Query pool metrics
        QueuePool-->>Logger: log_pool_status_failure (warning)
    end
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly Related PRs

  • Fix/db connection pool limit #740 — Extended the same file (backend/app/celery/celery_app.py) with initial task_prerun pool logging; this PR adds complementary task_postrun and task_failure handlers to complete the monitoring lifecycle.

Suggested Reviewers

  • vprashrex

Poem

🐰 Hops through signals, left and right,
Logging pools both day and night,
When tasks begin, complete, or fail,
The metrics flow without travail,

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/db-connection-pool-limit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Prajna1999 Prajna1999 merged commit 60dd566 into main Apr 9, 2026
1 check passed
@Prajna1999 Prajna1999 deleted the fix/db-connection-pool-limit branch April 9, 2026 04:48
@Prajna1999 Prajna1999 restored the fix/db-connection-pool-limit branch April 9, 2026 04:48
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/celery/celery_app.py 33.33% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant