Skip to content

Commit 78ee54e

Browse files
dahliaclaude
andcommitted
Document PostgreSQL pool sizing with ParallelMessageQueue
When `PostgresMessageQueue` is used together with `ParallelMessageQueue(queue, N)`, the PostgreSQL connection pool must be sized larger than `N`. Using the default pool size of 10 with `ParallelMessageQueue(queue, 10)` can cause connection starvation that makes the application appear hung. Added warnings in both the `PostgresMessageQueue` section and the parallel message processing section explaining this requirement and recommending a dedicated pool when the pool is shared with other parts of the application. Closes #603 [ci skip] Co-Authored-By: Claude <claude@anthropic.com>
1 parent 8b21c62 commit 78ee54e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/manual/mq.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,22 @@ const federation = createFederation<void>({
221221
});
222222
~~~~
223223

224+
> [!WARNING]
225+
> When using `PostgresMessageQueue` together with
226+
> [`ParallelMessageQueue`](#parallel-message-processing)`(queue, N)`,
227+
> make sure the PostgreSQL connection pool is sized to at least `N` plus a few
228+
> extra connections. This is because each parallel worker may hold a database
229+
> connection, and poll operations also require additional connections for
230+
> advisory lock management. If the pool is shared with other parts of your
231+
> application (e.g., a KV store, HTTP request handlers), increase the pool size
232+
> accordingly—or use a dedicated pool for the queue. Using the default pool
233+
> size of 10 with `ParallelMessageQueue(queue, 10)` can cause connection
234+
> starvation that makes the application appear hung. [[#603]]
235+
224236
[`PostgresMessageQueue`]: https://jsr.io/@fedify/postgres/doc/mq/~/PostgresMessageQueue
225237
[`LISTEN`]: https://www.postgresql.org/docs/current/sql-listen.html
226238
[`NOTIFY`]: https://www.postgresql.org/docs/current/sql-notify.html
239+
[#603]: https://github.com/fedify-dev/fedify/issues/603
227240

228241
### `AmqpMessageQueue`
229242

@@ -728,6 +741,14 @@ const federation = createFederation<void>({
728741
> running multiple nodes of your application so that each node can process
729742
> messages in parallel with the shared message queue.
730743
744+
> [!WARNING]
745+
> When using `ParallelMessageQueue(queue, N)` with [`PostgresMessageQueue`],
746+
> make sure the PostgreSQL connection pool is sized to at least `N` plus a few
747+
> extra connections. If the pool is shared with other parts of your application
748+
> (e.g., a KV store, HTTP request handlers), increase the pool size
749+
> accordingly—or use a dedicated pool for the queue. See the
750+
> [*`PostgresMessageQueue`* section](#postgresmessagequeue) for details.
751+
731752

732753
Separating message processing from the main process
733754
---------------------------------------------------

0 commit comments

Comments
 (0)