[Bug/Performance]: Inconsistent async DB usage in fetch_parsing_status causes blocking calls
#639 opened on Feb 24, 2026
Repository metrics
- Stars
- (5,521 stars)
- PR merge metrics
- (PR metrics pending)
Description
Component/Module
Parsing (Graph Construction)
Feature Type
Bug Fix / Performance Enhancement
Problem Statement
The ParsingController.fetch_parsing_status method in app/modules/parsing/graph_construction/parsing_controller.py is declared as async but uses a synchronous SQLAlchemy Session and calls db.execute(...) directly.
This mixes blocking database I/O inside an asynchronous FastAPI handler. Doing this can block the event loop and significantly reduce throughput and performance under load. It is also inconsistent with the fetch_parsing_status_by_repo method in the same file, which correctly uses AsyncSession and await for its database access.
Proposed Solution
The async controller method should be completely non-blocking. To achieve this:
- Change the
fetch_parsing_statusmethod signature to acceptdb: AsyncSessioninstead of a synchronousSession. - Update the router/dependencies that call this method to provide an
AsyncSession. - Replace the synchronous
result = db.execute(project_query)execution with the asynchronous pattern:result = await db.execute(project_query). - Note: If
ParseHelperinside this method requires a synchronousSession, you must either adapt it to use async DB accesses, or delegate its blocking parts to a separate thread viaasyncio.to_thread(or a dedicated synchronous service layer).
Current Implementation:
fetch_parsing_statusacceptsdb: Session.- It calls
db.execute(project_query)synchronously inside anasync def.
After this change:
- The method accepts an
AsyncSessionand awaits DB queries. - Operations match the correct async patterns already established by
fetch_parsing_status_by_repo.
Use Case
FastAPI relies on the asyncio event loop. By removing blocking I/O calls from async handlers, we ensure that the API can handle more concurrent requests without introducing performance bottlenecks during parsing status checks.
Additional Context
Where to look:
app/modules/parsing/graph_construction/parsing_controller.py- Look atfetch_parsing_statusand compare it tofetch_parsing_status_by_repo.
Skill level needed: Intermediate Python. Familiarity with FastAPI, SQLAlchemy, and Python's asyncio is required.
Feel free to comment if you have any questions before you start!