Skip to content

Comments

feat(postgres): support per-connection poolSize in replication config#11970

Open
ha1f wants to merge 2 commits intotypeorm:masterfrom
ha1f:feat/postgres-per-connection-pool-size
Open

feat(postgres): support per-connection poolSize in replication config#11970
ha1f wants to merge 2 commits intotypeorm:masterfrom
ha1f:feat/postgres-per-connection-pool-size

Conversation

@ha1f
Copy link

@ha1f ha1f commented Feb 10, 2026

Description of change

Allow primary and replica connections to specify individual poolSize in PostgreSQL replication configuration, matching the existing MySQL driver behavior added in #11810.

Currently, PostgreSQL replication config only supports a global poolSize via PostgresConnectionOptions. This PR adds poolSize to PostgresConnectionCredentialsOptions so that each primary/replica connection can have its own pool size, with fallback to the global setting for backward compatibility.

Fixes #11972

Changes:

  • PostgresConnectionCredentialsOptions: Added optional poolSize property
  • PostgresDriver.createPool(): Changed max: options.poolSizemax: credentials.poolSize ?? options.poolSize
  • Documentation updated with per-connection poolSize example

Related: #11810 (MySQL: same feature)

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #11972
  • There are new or updated tests validating the change (tests/**.test.ts) - N/A (pool size is not directly observable via query; matches MySQL PR feat(mysql): add pool size options for each connection #11810 which also has no tests)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@qodo-free-for-open-source-projects

User description

Description of change

Allow primary and replica connections to specify individual poolSize in PostgreSQL replication configuration, matching the existing MySQL driver behavior added in #11810.

Currently, PostgreSQL replication config only supports a global poolSize via PostgresConnectionOptions. This PR adds poolSize to PostgresConnectionCredentialsOptions so that each primary/replica connection can have its own pool size, with fallback to the global setting for backward compatibility.

Fixes #11972

Changes:

  • PostgresConnectionCredentialsOptions: Added optional poolSize property
  • PostgresDriver.createPool(): Changed max: options.poolSizemax: credentials.poolSize ?? options.poolSize
  • Documentation updated with per-connection poolSize example

Related: #11810 (MySQL: same feature)

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #11972
  • There are new or updated tests validating the change (tests/**.test.ts) - N/A (pool size is not directly observable via query; matches MySQL PR feat(mysql): add pool size options for each connection #11810 which also has no tests)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

PR Type

Enhancement


Description

  • Add per-connection poolSize support to PostgreSQL replication config

  • Allow master and slave connections to override global pool size

  • Fallback to global poolSize when per-connection value not specified

  • Update documentation with per-connection poolSize examples


Diagram Walkthrough

flowchart LR
  A["PostgresConnectionCredentialsOptions"] -->|"adds poolSize property"| B["Per-connection pool configuration"]
  C["PostgresDriver.createPool()"] -->|"uses credentials.poolSize ?? options.poolSize"| B
  B -->|"overrides"| D["Global poolSize fallback"]
  E["Documentation"] -->|"updated with examples"| F["Replication poolSize guide"]
Loading

File Walkthrough

Relevant files
Enhancement
PostgresConnectionCredentialsOptions.ts
Add poolSize property to credentials options                         

src/driver/postgres/PostgresConnectionCredentialsOptions.ts

  • Added optional poolSize property to
    PostgresConnectionCredentialsOptions interface
  • Allows individual primary/replica connections to specify their own
    pool size
  • Includes JSDoc comment describing the property
+6/-0     
PostgresDriver.ts
Use per-connection poolSize with fallback logic                   

src/driver/postgres/PostgresDriver.ts

  • Modified createPool() method to use credentials.poolSize ??
    options.poolSize instead of just options.poolSize
  • Enables per-connection pool size with fallback to global setting
  • Added JSDoc parameter documentation to multiple methods for improved
    code clarity
  • Fixed minor formatting in JSDoc comments
+39/-2   
Documentation
3-multiple-data-sources.md
Document per-connection poolSize for replication                 

docs/docs/data-source/3-multiple-data-sources.md

  • Added comprehensive example showing per-connection poolSize
    configuration for MySQL and PostgreSQL replication
  • Documented fallback behavior when poolSize is not specified on
    individual connections
  • Updated section header to reflect support for both MySQL and
    PostgreSQL
  • Clarified that MySQL replication supports additional configuration
    options
+28/-1   

@qodo-free-for-open-source-projects
Copy link

qodo-free-for-open-source-projects bot commented Feb 10, 2026

PR Code Suggestions ✨

Latest suggestions up to b12da43

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate per-connection pool size

Add validation to ensure the per-connection poolSize is a positive integer
before use, falling back to the global poolSize if the value is invalid.

src/driver/postgres/PostgresDriver.ts [1632-1648]

+const resolvedPoolSize =
+    Number.isSafeInteger(credentials.poolSize) && credentials.poolSize! > 0
+        ? credentials.poolSize
+        : options.poolSize
+
 const connectionOptions = Object.assign(
     {},
     {
         connectionString: credentials.url,
         host: credentials.host,
         user: credentials.username,
         password: credentials.password,
         database: credentials.database,
         port: credentials.port,
         ssl: credentials.ssl,
         connectionTimeoutMillis: options.connectTimeoutMS,
         application_name:
             options.applicationName ?? credentials.applicationName,
-        max: credentials.poolSize ?? options.poolSize,
+        max: resolvedPoolSize,
     },
     options.extra || {},
 )

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that the newly added poolSize option lacks validation, which could lead to runtime errors if an invalid value is provided, and proposes a robust check.

Low
General
Correct replication example ports

Correct the documentation example to use a more appropriate port for PostgreSQL,
or provide separate examples, to avoid misleading users.

docs/docs/data-source/3-multiple-data-sources.md [307-330]

 MySQL and PostgreSQL replication connections support per-connection `poolSize`:
 
 ```typescript
 {
   replication: {
     master: {
       host: "server1",
-      port: 3306,
+      port: 5432,
       username: "test",
       password: "test",
       database: "test",
       poolSize: 20,      // override global poolSize for master
     },
     slaves: [{
       host: "server2",
-      port: 3306,
+      port: 5432,
       username: "test",
       password: "test",
       database: "test",
       poolSize: 50,      // override global poolSize for this slave
     }],
   }
 }


- [ ] **Apply / Chat** <!-- /improve --apply_suggestion=1 -->


<details><summary>Suggestion importance[1-10]: 5</summary>

__

Why: The suggestion correctly points out that the documentation example uses a MySQL-specific port (`3306`) for a feature that also supports PostgreSQL, which could confuse users.

</details></details></td><td align=center>Low

</td></tr>
<tr><td align="center" colspan="2">

- [ ] More <!-- /improve --more_suggestions=true -->

</td><td></td></tr></tbody></table>

___

#### Previous suggestions


<details><summary>Suggestions up to commit f4340b3</summary>
<br><table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td>
<td>



<details><summary>Validate pool size before use</summary>

___

**Add validation to ensure the <code>poolSize</code> is a positive integer before passing it to <br>the connection pool options, throwing an error for invalid values.**

[src/driver/postgres/PostgresDriver.ts [1632-1648]](https://github.com/typeorm/typeorm/pull/11970/files#diff-3346a7798b4db06d6debd87138bb8322626b91c1c325b730d51ee3afc1b4c2bbR1632-R1648)

```diff
+const resolvedPoolSize = credentials.poolSize ?? options.poolSize
+if (
+    resolvedPoolSize !== undefined &&
+    (!Number.isInteger(resolvedPoolSize) || resolvedPoolSize <= 0)
+) {
+    throw new TypeORMError(
+        `Invalid poolSize value: ${resolvedPoolSize}. poolSize must be a positive integer.`,
+    )
+}
+
 const connectionOptions = Object.assign(
     {},
     {
         connectionString: credentials.url,
         host: credentials.host,
         user: credentials.username,
         password: credentials.password,
         database: credentials.database,
         port: credentials.port,
         ssl: credentials.ssl,
         connectionTimeoutMillis: options.connectTimeoutMS,
         application_name:
             options.applicationName ?? credentials.applicationName,
-        max: credentials.poolSize ?? options.poolSize,
+        max: resolvedPoolSize,
     },
     options.extra || {},
 )
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential runtime issue from invalid poolSize values and proposes adding validation, which improves the robustness of the connection pool creation.

Medium
Suggestions up to commit 6b450f2
CategorySuggestion                                                                                                                                    Impact
Possible issue
Enforce per-connection pool precedence

Reorder the Object.assign arguments to ensure the poolSize from credentials or
options takes precedence over any max value provided in options.extra.

src/driver/postgres/PostgresDriver.ts [1632-1648]

 const connectionOptions = Object.assign(
     {},
     {
         connectionString: credentials.url,
         host: credentials.host,
         user: credentials.username,
         password: credentials.password,
         database: credentials.database,
         port: credentials.port,
         ssl: credentials.ssl,
         connectionTimeoutMillis: options.connectTimeoutMS,
         application_name:
             options.applicationName ?? credentials.applicationName,
+    },
+    options.extra || {},
+    {
         max: credentials.poolSize ?? options.poolSize,
     },
-    options.extra || {},
 )
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a logical flaw where options.extra.max would override the intended poolSize, defeating the purpose of the PR. This is a critical fix for the new feature's correctness.

High
Validate pool size values

Add a validation check to ensure the poolSize is a positive, finite number
before it is used to configure the connection pool.

src/driver/postgres/PostgresDriver.ts [1632-1648]

+const poolSize = credentials.poolSize ?? options.poolSize
+if (
+    poolSize !== undefined &&
+    (!Number.isFinite(poolSize) || poolSize <= 0)
+) {
+    throw new TypeORMError(`Invalid poolSize: ${poolSize}`)
+}
+
 const connectionOptions = Object.assign(
     {},
     {
         connectionString: credentials.url,
         host: credentials.host,
         user: credentials.username,
         password: credentials.password,
         database: credentials.database,
         port: credentials.port,
         ssl: credentials.ssl,
         connectionTimeoutMillis: options.connectTimeoutMS,
         application_name:
             options.applicationName ?? credentials.applicationName,
-        max: credentials.poolSize ?? options.poolSize,
+        max: poolSize,
     },
     options.extra || {},
 )
Suggestion importance[1-10]: 7

__

Why: The suggestion improves robustness by adding validation for poolSize to prevent invalid values from being passed to the underlying driver, which could cause runtime errors.

Medium
Suggestions up to commit de43143
CategorySuggestion                                                                                                                                    Impact
General
Fix docs-driver mismatch

Correct the documentation to state that only PostgreSQL replication supports
per-connection poolSize, as the MySQL driver has not been updated with this
feature.

docs/docs/data-source/3-multiple-data-sources.md [307]

-MySQL and PostgreSQL replication connections support per-connection `poolSize`:
+PostgreSQL replication connections support per-connection `poolSize`:
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly points out that the documentation is inaccurate, as the poolSize override functionality was only implemented for PostgreSQL, not MySQL, preventing user confusion.

High
Possible issue
Prevent unusable connection pool for poolSize of 0

To prevent an unusable connection pool when poolSize is 0, replace the nullish
coalescing operator (??) with the logical OR operator (||) to fall back to the
global options.poolSize.

src/driver/postgres/PostgresDriver.ts [1677]

-max: credentials.poolSize ?? options.poolSize,
+max: credentials.poolSize || options.poolSize,
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that a poolSize of 0 would create an unusable connection pool and proposes a simple, effective fix by changing ?? to ||.

Medium

@qodo-free-for-open-source-projects
Copy link

qodo-free-for-open-source-projects bot commented Feb 10, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Redundant @param JSDoc tags 📘 Rule violation ✓ Correctness
Description
A large number of new JSDoc @param tags were added without adding meaningful documentation, which
introduces comment noise and is inconsistent with the file’s prior style. This increases maintenance
burden and appears to violate the project requirement to avoid AI-generated slop.
Code

src/driver/postgres/PostgresDriver.ts[R715-727]

   /**
    * Creates a query runner used to execute database queries.
+     * @param mode
    */
   createQueryRunner(mode: ReplicationMode): PostgresQueryRunner {
       return new PostgresQueryRunner(this, mode)
   }

   /**
    * Prepares given value to a value to be persisted, based on its column type and metadata.
+     * @param value
+     * @param columnMetadata
    */
Evidence
PR Compliance ID 4 prohibits introducing AI-generated noise such as extra comments and inconsistent
style. The PR adds many repetitive @param tags across existing methods (example shown), which are
not necessary to explain behavior and create noticeable comment churn.

Rule 4: Remove AI-generated noise
src/driver/postgres/PostgresDriver.ts[715-728]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Numerous repetitive JSDoc `@param` tags were added across `PostgresDriver.ts`, creating comment noise and inconsistent style.
## Issue Context
The compliance checklist forbids adding AI-generated slop such as extra comments or inconsistent style. These tags do not add substantive documentation beyond what TypeScript types already convey.
## Fix Focus Areas
- src/driver/postgres/PostgresDriver.ts[714-1813]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. poolSize overridden by extra.max 🐞 Bug ✓ Correctness
Description
In PostgresDriver.createPool, the computed max (from per-connection poolSize) is assigned
before merging options.extra, so a globally configured extra.max will override it and silently
defeat per-connection poolSize.
Code

src/driver/postgres/PostgresDriver.ts[R1674-1680]

               connectionTimeoutMillis: options.connectTimeoutMS,
               application_name:
                   options.applicationName ?? credentials.applicationName,
-                max: options.poolSize,
+                max: credentials.poolSize ?? options.poolSize,
           },
           options.extra || {},
       )
Evidence
The pool config sets max from credentials.poolSize ?? options.poolSize but then merges
options.extra after, allowing extra.max to overwrite max. Since extra is explicitly
supported as a place for driver-specific settings, this can cause the newly documented
per-connection pool sizing to not apply in real configurations where users set extra.max.

src/driver/postgres/PostgresDriver.ts[1664-1680]
src/data-source/BaseDataSourceOptions.ts[90-134]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PostgresDriver.createPool` merges `options.extra` after setting `max`, which allows `extra.max` to override the newly added per-connection `poolSize` behavior.
### Issue Context
Many Postgres users configure pool sizing via driver-native `extra.max`. With the current merge order, per-connection `poolSize` can be silently ignored.
### Fix Focus Areas
- src/driver/postgres/PostgresDriver.ts[1664-1680]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. poolSize change lacks tests 📘 Rule violation ⛯ Reliability ⭐ New
Description
This PR changes PostgreSQL replication behavior by allowing per-connection poolSize, but no
functional test was added/updated to validate the regression and precedence logic. Lack of coverage
increases the risk of unnoticed breaking behavior in replication configs.
Code

src/driver/postgres/PostgresDriver.ts[R1643-1646]

                application_name:
                    options.applicationName ?? credentials.applicationName,
-                max: options.poolSize,
+                max: credentials.poolSize ?? options.poolSize,
            },
Evidence
Compliance ID 3 expects issue fixes to live in the functional test suite; the PR introduces a
behavior change (per-connection poolSize precedence) while the PR description indicates tests were
not added.

Rule 3: Prefer functional tests over per-issue tests
src/driver/postgres/PostgresDriver.ts[1643-1646]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A behavior change was introduced (per-connection `poolSize` overrides global `poolSize`) without a functional test to validate the precedence logic.

## Issue Context
Even if pool size is not observable via a SQL query, it can typically be verified by inspecting the driver/pool configuration (e.g., by mocking/stubbing `pg.Pool` and asserting the constructed options include `max` equal to the expected value for master/slave credentials).

## Fix Focus Areas
- src/driver/postgres/PostgresDriver.ts[1623-1648]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Docs: wrong MySQL extra key 🐞 Bug ✓ Correctness ⭐ New
Description
The replication docs state that setting pool size via extra: { max: ... } takes precedence for
both MySQL and PostgreSQL, but TypeORM maps MySQL pool sizing to connectionLimit (not max). This
is likely to mislead MySQL users into thinking extra.max will override poolSize when it will not
(at least not via TypeORM’s mapping).
Code

docs/docs/data-source/3-multiple-data-sources.md[R307-336]

+MySQL and PostgreSQL replication connections support per-connection `poolSize`:
+
+```typescript
+{
+  replication: {
+    master: {
+      host: "server1",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 20,      // override global poolSize for master
+    },
+    slaves: [{
+      host: "server2",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 50,      // override global poolSize for this slave
+    }],
+  }
+}
+```
+
+If `poolSize` is not specified on an individual connection, the global `poolSize` option will be used as a fallback.
+
+> Note: if you set pool size via `extra` (e.g. `extra: { max: 100 }`), it will take precedence over both global and per-connection `poolSize`.
+
+MySQL replication also supports these extra configuration options:
Evidence
The updated docs apply the extra: { max: 100 } precedence note to both MySQL and PostgreSQL
replication. In the codebase, Postgres uses the max pool option, while MySQL uses
connectionLimit; therefore extra.max is not the appropriate MySQL example key for overriding
pool size.

docs/docs/data-source/3-multiple-data-sources.md[307-336]
src/driver/postgres/PostgresDriver.ts[1631-1648]
src/driver/mysql/MysqlDriver.ts[1222-1235]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Replication docs say that setting pool size via `extra: { max: ... }` takes precedence for both **MySQL** and **PostgreSQL**, but `max` is the Postgres pool key; MySQL uses `connectionLimit` in TypeORM’s pool configuration.

### Issue Context
- Postgres driver maps `poolSize` -&gt; `max` and merges `options.extra` last, so `extra.max` can override.
- MySQL driver maps `poolSize` -&gt; `connectionLimit` and merges `options.extra` last, so to override via `extra` the key must be `connectionLimit`.

### Fix Focus Areas
- docs/docs/data-source/3-multiple-data-sources.md[307-336]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. poolSize comment fragment 📘 Rule violation ✓ Correctness
Description
The new poolSize JSDoc contains a sentence fragment (for each connection) and inconsistent
capitalization, which reads as low-quality/noisy documentation. This conflicts with the requirement
to avoid AI-generated slop and maintain consistent style.
Code

src/driver/postgres/PostgresConnectionCredentialsOptions.ts[R48-52]

+    /**
+     * Maximum number of clients the pool should contain.
+     * for each connection
+     */
+    readonly poolSize?: number
Evidence
PR Compliance ID 4 requires avoiding AI-like comments and style inconsistencies. The newly added
poolSize comment includes an incomplete fragment and inconsistent formatting, suggesting
generated/low-quality documentation.

Rule 4: Remove AI-generated noise
src/driver/postgres/PostgresConnectionCredentialsOptions.ts[48-52]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `poolSize` JSDoc contains a sentence fragment and inconsistent capitalization.
## Issue Context
The project compliance checklist discourages AI-generated/noisy comments and inconsistent style.
## Fix Focus Areas
- src/driver/postgres/PostgresConnectionCredentialsOptions.ts[48-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
6. Doc example uses 3306 🐞 Bug ✓ Correctness
Description
Docs state PostgreSQL replication supports per-connection poolSize, but the shared example uses
MySQL’s default port (3306) and reads as MySQL-specific, which can mislead PostgreSQL users into
copy/paste misconfiguration.
Code

docs/docs/data-source/3-multiple-data-sources.md[R307-327]

+MySQL and PostgreSQL replication connections support per-connection `poolSize`:
+
+```typescript
+{
+  replication: {
+    master: {
+      host: "server1",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 20,      // override global poolSize for master
+    },
+    slaves: [{
+      host: "server2",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 50,      // override global poolSize for this slave
+    }],
Evidence
The updated documentation explicitly claims MySQL and PostgreSQL support per-connection poolSize,
but the example uses port 3306 for both master and slaves, which is not the typical PostgreSQL port
and is likely to cause connection failures if copied directly.

docs/docs/data-source/3-multiple-data-sources.md[305-333]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The docs section claims both MySQL and PostgreSQL replication support per-connection `poolSize`, but the example is MySQL-centric (port 3306), which can mislead PostgreSQL users.
### Issue Context
This is a documentation-only issue but likely to cause copy/paste misconfiguration.
### Fix Focus Areas
- docs/docs/data-source/3-multiple-data-sources.md[307-333]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Grey Divider

Previous review results

Review updated until commit b12da43

Results up to commit 6b450f2


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit de43143


🐞 Bugs (2) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider
Action required
1. Redundant @param JSDoc tags 📘 Rule violation ✓ Correctness
Description
A large number of new JSDoc @param tags were added without adding meaningful documentation, which
introduces comment noise and is inconsistent with the file’s prior style. This increases maintenance
burden and appears to violate the project requirement to avoid AI-generated slop.
Code

src/driver/postgres/PostgresDriver.ts[R715-727]

    /**
     * Creates a query runner used to execute database queries.
+     * @param mode
     */
    createQueryRunner(mode: ReplicationMode): PostgresQueryRunner {
        return new PostgresQueryRunner(this, mode)
    }

    /**
     * Prepares given value to a value to be persisted, based on its column type and metadata.
+     * @param value
+     * @param columnMetadata
     */
Evidence
PR Compliance ID 4 prohibits introducing AI-generated noise such as extra comments and inconsistent
style. The PR adds many repetitive @param tags across existing methods (example shown), which are
not necessary to explain behavior and create noticeable comment churn.

Rule 4: Remove AI-generated noise
src/driver/postgres/PostgresDriver.ts[715-728]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Numerous repetitive JSDoc `@param` tags were added across `PostgresDriver.ts`, creating comment noise and inconsistent style.

## Issue Context
The compliance checklist forbids adding AI-generated slop such as extra comments or inconsistent style. These tags do not add substantive documentation beyond what TypeScript types already convey.

## Fix Focus Areas
- src/driver/postgres/PostgresDriver.ts[714-1813]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. poolSize overridden by extra.max 🐞 Bug ✓ Correctness
Description
In PostgresDriver.createPool, the computed max (from per-connection poolSize) is assigned
before merging options.extra, so a globally configured extra.max will override it and silently
defeat per-connection poolSize.
Code

src/driver/postgres/PostgresDriver.ts[R1674-1680]

                connectionTimeoutMillis: options.connectTimeoutMS,
                application_name:
                    options.applicationName ?? credentials.applicationName,
-                max: options.poolSize,
+                max: credentials.poolSize ?? options.poolSize,
            },
            options.extra || {},
        )
Evidence
The pool config sets max from credentials.poolSize ?? options.poolSize but then merges
options.extra after, allowing extra.max to overwrite max. Since extra is explicitly
supported as a place for driver-specific settings, this can cause the newly documented
per-connection pool sizing to not apply in real configurations where users set extra.max.

src/driver/postgres/PostgresDriver.ts[1664-1680]
src/data-source/BaseDataSourceOptions.ts[90-134]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`PostgresDriver.createPool` merges `options.extra` after setting `max`, which allows `extra.max` to override the newly added per-connection `poolSize` behavior.

### Issue Context
Many Postgres users configure pool sizing via driver-native `extra.max`. With the current merge order, per-connection `poolSize` can be silently ignored.

### Fix Focus Areas
- src/driver/postgres/PostgresDriver.ts[1664-1680]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
3. poolSize comment fragment 📘 Rule violation ✓ Correctness
Description
The new poolSize JSDoc contains a sentence fragment (for each connection) and inconsistent
capitalization, which reads as low-quality/noisy documentation. This conflicts with the requirement
to avoid AI-generated slop and maintain consistent style.
Code

src/driver/postgres/PostgresConnectionCredentialsOptions.ts[R48-52]

+    /**
+     * Maximum number of clients the pool should contain.
+     * for each connection
+     */
+    readonly poolSize?: number
Evidence
PR Compliance ID 4 requires avoiding AI-like comments and style inconsistencies. The newly added
poolSize comment includes an incomplete fragment and inconsistent formatting, suggesting
generated/low-quality documentation.

Rule 4: Remove AI-generated noise
src/driver/postgres/PostgresConnectionCredentialsOptions.ts[48-52]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `poolSize` JSDoc contains a sentence fragment and inconsistent capitalization.

## Issue Context
The project compliance checklist discourages AI-generated/noisy comments and inconsistent style.

## Fix Focus Areas
- src/driver/postgres/PostgresConnectionCredentialsOptions.ts[48-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Doc example uses 3306 🐞 Bug ✓ Correctness
Description
Docs state PostgreSQL replication supports per-connection poolSize, but the shared example uses
MySQL’s default port (3306) and reads as MySQL-specific, which can mislead PostgreSQL users into
copy/paste misconfiguration.
Code

docs/docs/data-source/3-multiple-data-sources.md[R307-327]

+MySQL and PostgreSQL replication connections support per-connection `poolSize`:
+
+```typescript
+{
+  replication: {
+    master: {
+      host: "server1",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 20,      // override global poolSize for master
+    },
+    slaves: [{
+      host: "server2",
+      port: 3306,
+      username: "test",
+      password: "test",
+      database: "test",
+      poolSize: 50,      // override global poolSize for this slave
+    }],
Evidence
The updated documentation explicitly claims MySQL and PostgreSQL support per-connection poolSize,
but the example uses port 3306 for both master and slaves, which is not the typical PostgreSQL port
and is likely to cause connection failures if copied directly.

docs/docs/data-source/3-multiple-data-sources.md[305-333]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The docs section claims both MySQL and PostgreSQL replication support per-connection `poolSize`, but the example is MySQL-centric (port 3306), which can mislead PostgreSQL users.

### Issue Context
This is a documentation-only issue but likely to cause copy/paste misconfiguration.

### Fix Focus Areas
- docs/docs/data-source/3-multiple-data-sources.md[307-333]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider Grey Divider
Qodo Logo

@ha1f ha1f force-pushed the feat/postgres-per-connection-pool-size branch 2 times, most recently from 6b450f2 to f4340b3 Compare February 10, 2026 14:12
@qodo-free-for-open-source-projects

Persistent review updated to latest commit 6b450f2

@ha1f ha1f force-pushed the feat/postgres-per-connection-pool-size branch from f4340b3 to b12da43 Compare February 10, 2026 14:15
@qodo-free-for-open-source-projects

Persistent review updated to latest commit f4340b3

@qodo-free-for-open-source-projects

Persistent review updated to latest commit b12da43

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.

Support individual poolSize for master/slave in PostgreSQL replication

1 participant