Context
I am opening this issue to discuss the architectural approach for the GSoC '26 project: Implementing event-driven concurrency in OLTP test tool (DBT-5).
While tracing the connection flow in the BrokerageHouse module, I mapped out the current concurrency model and wanted to align on the strategy for handling the database layer before drafting a PoC patch.
Current State
Currently, the listener accepts a socket, and entryWorkerThread() spawns a detached workerThread() per connection. Each thread maintains its own DB connection and blocking receive loop.
The libev Refactor & The Bottleneck
A straightforward refactor to libev would replace the pthread_create path with per-connection ev_io watchers, moving the socket I/O entirely into the event loop.
The architectural challenge: The transaction handlers ultimately invoke synchronous, blocking database calls. If these are executed directly inside the libev event callback, a single slow DB query will block the entire event loop, freezing all other network I/O.
Discussion: Direction for the DB Layer
To prevent the event loop from blocking, how are we envisioning the database layer transition?
Are we leaning toward:
- Fully Asynchronous: A transition toward asynchronous DB drivers (e.g., using non-blocking calls like
PQsendQuery if targeting PostgreSQL directly, wrapping them in their own libev watchers).
- Hybrid Thread-Pool Model:
libev strictly handles network I/O (accepting connections and reading/writing buffers), but dispatches the actual blocking DB transactions to a bounded, fixed-size worker thread pool.
Would love to get the maintainers' thoughts on which direction aligns best with the long-term goals for DBT-5.
Context
I am opening this issue to discuss the architectural approach for the GSoC '26 project: Implementing event-driven concurrency in OLTP test tool (DBT-5).
While tracing the connection flow in the
BrokerageHousemodule, I mapped out the current concurrency model and wanted to align on the strategy for handling the database layer before drafting a PoC patch.Current State
Currently, the listener accepts a socket, and
entryWorkerThread()spawns a detachedworkerThread()per connection. Each thread maintains its own DB connection and blocking receive loop.The libev Refactor & The Bottleneck
A straightforward refactor to
libevwould replace thepthread_createpath with per-connectionev_iowatchers, moving the socket I/O entirely into the event loop.The architectural challenge: The transaction handlers ultimately invoke synchronous, blocking database calls. If these are executed directly inside the
libevevent callback, a single slow DB query will block the entire event loop, freezing all other network I/O.Discussion: Direction for the DB Layer
To prevent the event loop from blocking, how are we envisioning the database layer transition?
Are we leaning toward:
PQsendQueryif targeting PostgreSQL directly, wrapping them in their ownlibevwatchers).libevstrictly handles network I/O (accepting connections and reading/writing buffers), but dispatches the actual blocking DB transactions to a bounded, fixed-size worker thread pool.Would love to get the maintainers' thoughts on which direction aligns best with the long-term goals for DBT-5.