You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
[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.
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 </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.
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.
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.
Correct the documentation to state that only PostgreSQL replication supports per-connection poolSize, as the MySQL driver has not been updated with this feature.
-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.
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 ||.
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.
/**
* 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.
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.
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.
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
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.
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.
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).
+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.
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` -> `max` and merges `options.extra` last, so `extra.max` can override.
- MySQL driver maps `poolSize` -> `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.
+ /**+ * 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.
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.
+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.
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
ⓘ The new review experience is currently in Beta. Learn more
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.
/**
* 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.
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.
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.
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
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.
+ /**+ * 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.
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.
+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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
Allow primary and replica connections to specify individual
poolSizein PostgreSQL replication configuration, matching the existing MySQL driver behavior added in #11810.Currently, PostgreSQL replication config only supports a global
poolSizeviaPostgresConnectionOptions. This PR addspoolSizetoPostgresConnectionCredentialsOptionsso 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 optionalpoolSizepropertyPostgresDriver.createPool(): Changedmax: options.poolSize→max: credentials.poolSize ?? options.poolSizepoolSizeexampleRelated: #11810 (MySQL: same feature)
Pull-Request Checklist
masterbranchFixes #11972tests/**.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)docs/docs/**.md)