Postgres: many requests at once no longer stop the site
Each Payload transaction holds a pool connection; code inside it that runs without its req needs a second one (Payload's own forgotPassword, the mail adapter's settings read and status write, payload.kv). With the default pool of 10, ten form submissions or ten "forgot password" requests at once held every connection and waited for good. - connectionReserve (default on): at most pool size − reserve transactions open at once; a waiter older than a second may use all but the last connection. Building blocks in modules/database/transactions.ts. - Form e-mails go out right after the submission's transaction commits, in the same request (forms.emailsInTransaction: true = the old way). - recordIntegrationStatus merges identical writes and does not hold its caller while the pool is busy. - SMTP time-outs: 10 s connect, 30 s greeting, 60 s silence (smtp.timeouts). Tests on Postgres 17: 30 submissions, 30 forgot-password, and both against an SMTP server that never answers, finish while a page answers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
acfcf72c03
commit
32bb542e8e
@@ -131,6 +131,31 @@ once there are more than 20.
|
||||
Not a switch for a live site: it would start visitors' histories and the running 2FA counts again.
|
||||
- `EnvRule.aliases` for `assertEnv`: older names of a variable, read when the main one is missing.
|
||||
|
||||
### Fixed — Postgres: many requests at once no longer stop the site (draft; release decided by the owner)
|
||||
- **Ten or more form submissions at the same moment, or ten "forgot password" requests, stopped the whole site on
|
||||
Postgres** — every request, also pages that only read, waited for good (older than 1.17.0; MongoDB sites were not
|
||||
affected). Each transaction holds a pool connection, and code inside it that runs without its `req` (Payload's own
|
||||
"forgot password", the e-mail adapter reading Site integrations and writing the send status, `payload.kv`) needs a
|
||||
second one; the default pool has 10. Measured on Postgres 17: 12 submissions or 12 resets at once never finished;
|
||||
now 30 of each, also against an SMTP server that never answers, finish while an ordinary request answers at once.
|
||||
- **`connectionReserve`** (new plugin option, default on): a fifth of the pool, at least 2, stays free of
|
||||
transactions; at most `pool size − reserve` transactions are open at once and the next one waits; one that has
|
||||
waited a second may use all but the last connection. `false` = as before. Building blocks `reserveConnections`,
|
||||
`watchTransactions`, `afterCommit`, `inWatchedTransaction`, `transactionsBusy`, `transactionWatchState`,
|
||||
`poolSize`, `defaultConnectionReserve`, `RESERVE_ESCAPE_MS` ([deployment.md](./deployment.md) §4.3a).
|
||||
- **Form e-mails go out after the submission's transaction commits** — same request, same answer to the visitor
|
||||
(a file that could not be sent is still reported). A submission rolled back by a later hook now sends nothing; a
|
||||
send that fails after the commit leaves the submission stored (as a failed e-mail always did). Sites without
|
||||
transactions (MongoDB without a replica set, SQLite) send at once, as before. The old way:
|
||||
`forms: { emailsInTransaction: true }`. Building blocks `sendAfterCommit`, `sendFormEmails`
|
||||
([forms.md](./forms.md) "When e-mails go out").
|
||||
- **The panel's send status** (`recordIntegrationStatus`): many sends failing at once write it once; while the pool
|
||||
is busy the write is not waited for.
|
||||
- **SMTP time-outs**: 10 s to connect (was nodemailer's 2 min), 30 s for the greeting, 60 s of silence (was 10 min);
|
||||
`mailAdapter({ smtp: { timeouts } })` / `panelSmtpAdapter({ timeouts })`, `SMTP_TIMEOUT_DEFAULTS`, `SmtpTimeouts`.
|
||||
- Not fixed here: Payload's own "forgot password" and "verify your e-mail" still send inside their transaction, so a
|
||||
hanging mail server makes them hold a place until the SMTP time-out (others wait; nothing stops).
|
||||
|
||||
### Deprecated
|
||||
- **Microsoft Graph as an e-mail transport** — `graphAdapter`, `GraphAdapterArgs`, `mailAdapter({ graph })`,
|
||||
`iaplEnvRules({ emailGraph })` and the four `GRAPH_*` variables. Nothing new is built on it; it gets fixes only and
|
||||
|
||||
Reference in New Issue
Block a user